Question 1[4 marks]Zara has created the following program in her computer science lesson. The aim of this program is to find out if the user is old enough to vote or not, the voting age being 18 years old. If the user is too young to vote, the program will calculate and output in how many years the user will be allowed to vote!
Here is his Python code:
#Voting Age Checker
a = int(input("How old are you?"))
print(You can vote!")
y = 18 - a
print("You will be allowed to vote in " + str(y) + " years!")
Zara made two errors in her code. A syntax error and a logic error. Identify these two errors and explain how these could be fixed.
Question 2[2 marks]Explain the difference between a logic error and a syntax error.
Question 3[3 marks]In order to test her program, Zara is designing a test plan. She wants to use specific input values to complete three types of tests:
- Valid Tests
- Borderline/Extreme Tests
- Erroneous Tests
- Valid Test Data:
- Borderline/Extreme Test Data:
- Erroneous Test Data:
Question 4[2 marks]Identify two purposes of testing.
Question 5[2 marks]Identify two ways, Zara could use to make her code easier to understand and maintain.
Question 6[5 marks]Zara would like to create a function using her code. The function should be called checkVotingAge(). It should
- take one parameter (the age of the user as an integer value),
- output the messages as it currently does
- return a Boolean value as to whether the user is allowed to vote or not.