Section 4 Practice Tasks

Practice Tasks for Selection

1. Create a very simple Spanish translation program. Let the user enter a number between one and four (“one”, “two”, “three” or “four”). If they enter “one” then print “uno”, else if (elif) they enter “two” then print “dos”, else if they enter “three” print “tres” and for “four” print “cuatro”. If they enter anything else print “I don’t know any more Spanish!” It could look like this:

if6


2. Create a program where the user enters their age. If the value that they have entered is 18 or over then print the sentence “You can legally vote!” but if any other value is entered then print “You are too young to vote!”.


3. Create a program that asks the user their name. If their name is Craig or David then print “What’s your flavour?” otherwise print “Hello” and their name.


4. Ask the user to enter a first number and then a second number. Multiply the two number together. If the total is more than 9000 print “IT’S OVER 9000!!” otherwise print the total.


< Back to Section Four