
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This is the pdf of python if statements.
Typology: Exercises
1 / 1
This page cannot be seen from the preview
Don't miss anything!

© Nichola Wilkin Ltd. 201 7
Challenge ID Challenge IF_001 Ask for two numbers, if the first one is larger than the second display the second number first and then the first number otherwise show the first number first and the second. IF_002 Ask then to enter a number that is under 20. If they enter a number that is 20 or more, display the message “Too high” otherwise display “Thank you”. IF_003 Ask then to enter a number that between 10 and 20. If they enter within this range display the message “Thank you” otherwise display the message “Incorrect answer” IF_004 Ask them to enter their favourite colour. If they enter “red” (no matter what case they use) then display the message “I like red too” otherwise display the message “I don’t like that colour, I prefer red”.
Challenge ID Challenge IF_005 Ask them if it is raining. If they answer “yes” ask if it is windy. If they answer “yes” to this second question, display the answer “It is too windy for an umbrella” otherwise display the message “Take an umbrella”. If they did not answer yes to the first question display the answer “Enjoy your day” IF_006 Ask for their age, if they are 18 or over display the message “You can vote”, if they are age 17 display the message “You can learn to drive”, if they are 16 display the message “You can buy a lottery ticket” if they are under 16 display the message “You can go Trick-or-Treating”.
Challenge ID Challenge IF_007 Ask them to enter a number, if it is under 10 display the message “Too low”, if it is between 10 and 20 display “Correct, otherwise display “Too high” IF_008 Ask them to enter 1, 2 or 3. If they enter a 1 display the message “Thank you” if they enter a 2 display “Well done” if they enter a 3 display “Correct” if they enter anything else display “Error message”.