Python Programming · Middle Stage (6–8) · 2 courses, 28 worked problems, 40 practice questions
Python is a programming language that reads almost like English, which makes it a good first language. A program is a list of instructions that the computer carries out in order. On this site you type code in the editor and press Run to see the result. A first program can be one line: print("Hello"). Python can also act as a calculator, so print(3 * 4) shows 12. Comments start with # and are notes for people, not for the computer. Errors are normal, and the message Python gives tells you what to fix.
Choose an answer, then check it. Each one shows a full explanation.
A text is repeated with the star. What does print("ab" * 3) show?
A label and a sum in one print(): what does print("Total:", 2 + 5) show?
Which of these lines has a mistake?
A program has the comment # Say hello on line 1 and print("Hello") on line 2. How many lines does it show?
Each one has a hint, the key idea and a full worked solution.
Which terminal command goes up one folder?
You run python3 card.py in a terminal, and the program uses input(). How do you answer its question?
Which of these is a good name for a Python file?
A student types print("Hi") straight into the terminal, not inside Python, and gets an error. What is the mistake?
What does print("Hi", "there") show?
What does print(3 + 4) show?