60 min read
Python Worksheet
Multiple-choice theory questions and predict-the-output code, plus short programs to write.
About This Worksheet
Try each question without running code first. For the programs, write them yourself, then compare with the answer and run your version in an editor or an example box above.
Section A — Theory
Section B — Predict the Output
Run to check Section BPython
x = 5x += 3x *= 2print(x)for i in range(2, 9, 3): print(i)n = 1while n < 20: n = n * 3print(n)def square(n): return n * nprint(square(3) + square(4))Expected output
16 2 5 8 27 25
Section C — Write the Program
More lessons in Python Programming · Next: Programming Practice Exam · Previous: Debugging Your Programs
