Typing your first code
Answers are for parents and teachers.
1
Write three differences between Scratch and Python.
For example: Scratch is built with blocks but Python is typed; Python has syntax rules about brackets, quotation marks and spelling; Python is used for bigger, more advanced programs.
2
What does this program show? Write each line of output.
Python
1# Cafe sign 2print("Hot tea") 3print(12 + 6)
Two lines: Hot tea, then 18. The comment line is ignored, the first print shows text and the second print adds 12 and 6.
3
Write one line of Python that works out 6 packs of 12 eggs minus 5 broken eggs. What does the shell show?
(6 * 12) - 5, or 6 * 12 - 5. It shows 67, because 6 * 12 is 72 and 72 - 5 is 67.
4
Python stops before it shows anything. Find the mistake and write the correct line.
Python
1print("Fresh juice"))Output
SyntaxError: unmatched ')'
There is one closing bracket too many: one opening bracket needs exactly one closing bracket. This breaks the syntax rules. The correct line is print("Fresh juice").
5
Add a comment above each line to explain what it does. Then say why comments are useful.
Python
1print("Market stall") 2print(4 * 3) 3print("Open at 8")
Example: # shows the title, # shows the price, # shows the opening time. Comments help other people (and you, later) to understand the program, and Python ignores them.