9.05 Python Scheme of Work
9.05 Python Scheme of Work
print("What is 2 + 2?")
answer = input ()
answer = int(answer)
if answer == 4:
print("Well done")
else:
print("Sorry the answer was 4")
Question 2
Question 3
With just a few lines of extra code, it should be possible to
maintain a score throughout a game and then give the user some
feedback at the end.
Add the two highlighted lines of code to your FIRST question only
For the remaining 4 questions, just add the line
score = score + 1 #this increases score by one
…as shown below
print("What is 13 + 80?")
answer = input ()
answer = int(answer)
if answer == 93:
print("Well done")
score = score + 1 #this increases score by one
else:
print("Sorry the answer was 93")
We would also like to show the score after the user has attempted
answering the question. Remember, the score is stored in a
variable called score and is simply print(score)
Example
Tim, your score is 1