Coding Task: 02.01 I Vote to Vote

In this exercise, you’re going to finish coding a program that calculates how many years the user will have to wait until they can vote in Australia. The voting age in Australia is 18.

Your Task

In the editor below, fill in the blanks (________) so that the program asks for the age of the user, works out how many years until they can vote, and print the results back to the user. You will also need to fix this line of code as it contains an error (check the hint below if you can’t spot it):

years_remaining = 18 - age

Python Reference Sheet

Remember to use the Python reference sheet to help you with your code! Click on one of the buttons below:

Requirements

  • The program should run without any errors.
  • The program should convert the user’s input for age to an integer.
  • The program should calculate the difference between the user’s age and the legal voting age (18 in Australia) and print the result back to the user.
  • Hint: age will not be an integer by default, you will need to use the int() command to convert it!

Example

Below is an example of how the program should run:

Please enter your name: Alice
Please enter your age: 14
Hi Alice! You have...
4
year(s) remaining before you can vote in Australia!
Scroll to Top