SLSkillLoop
Python practice

Python Syntax Practice

Python syntax gets easier when you practice the small rules repeatedly. Use these examples to review indentation, expressions, strings, lists, and function structure.

Example practice questions

Try these samples, then continue into the Python Practice Labfor guided browser-based practice.

1

Which line correctly assigns the number 5 to a variable named score?

Answer: score = 5

2

Which character starts a Python comment?

Answer: #

3

What keyword starts a function definition?

Answer: def

4

What is missing from if score > 10?

Answer: A colon at the end: if score > 10:

5

Which syntax creates a list of three numbers?

Answer: [1, 2, 3]

6

Which keyword repeats over items in a list?

Answer: for

7

What does Python use to mark blocks of code?

Answer: Indentation