Selection Exercises

On this page you will find a range of additional exercises that will help you practice the IF statements. You may need to investigate the Python Documentation as well...


Exercises

  1. Extend exercise 5 from the previous set of additional exercises. As well as outputting how much volume remains in the lift, state whether the fridge would fit based on its dimensions. The program should tell you which dimension is the problem if it won't fit into the lift.
  2. Create a program which will ask the user for a distance and whether you will be travelling on Motorway, A-road or through town for the duration of travel. The program should output the minimum amount of time it will take to reach that distance.
  3. Ask the user to enter the current month, the program should output whether the month is in Winter, Spring, Summer or Autumn.
  4. Extend exercise 3 so that it will tell you the number of days in the given month (ignore leap years!).
  5. Create a program which will allow the user to enter the state of two switches (either 1 (on) or 0 (off)). The program should work out if both switches are on and then output the message 'the light is on'. Otherwise, the program should output the message 'the light is off'.
  6. Amend your program so that the program will switch the light on if either of the switches is on.
  7. Create a program which asks the user for 3 numbers representing the year, month and day e.g 1982 10 08 and then outputs in the form 8th October 1982.
  8. Create a program which will troubleshoot printing problems. The program should ask questions like 'is the printer turned on?' and 'is there paper in the printer'.
  9. Create a program which will ask for your recent exam score out of 60 and tell you what grade you got and how many more marks you would have needed to get the next grade up. You can decide on the grade boundaries yourself.
  10. Extend exercise 4 so that it takes into consideration leap years - Wikipedia Leap Years.