Python makes the choice
Answers are for parents and teachers.
1
Write a Python program: ask for the number of pages in a book. If it is more than 100, print Long book, otherwise print Short book.
Model answer (lines are separated by /, and [indent] means four spaces at the start of the line): pages = int(input("Pages? ")) / if pages > 100: / [indent] print("Long book") / else: / [indent] print("Short book")
2
Say what is printed for the inputs 7 and 70.
Python
1percent = int(input("Battery? ")) 2if percent < 10: 3 print("Low") 4else: 5 print("OK")
7: Low. 70: OK.
3
Plan an if statement in three steps for: print Bring a coat when the temperature is below 12.
Step 1: input temp, a whole number. Step 2: condition temp < 12. Step 3: when true print Bring a coat; when false print nothing (or another message).
4
Explain the difference between = and == in Python, with one example of each.
= stores a value in a variable, for example score = 5. == compares two values and gives True or False, for example score == 5.
5
A pupil types Cairo with a small c and the program says Wrong. Explain why, and say how the program could be made fairer (for later).
Python is case-sensitive, so cairo is not equal to Cairo. A fairer program could accept several spellings, which you will learn to do with or.