Chapters
Python114 chapters

Exercises

Get Started

3 tasks. Write the code, press Check, and the page runs it against a real Python interpreter.

Exercise 1

A file needs print() to show anything. Make this print 4 rather than computing it silently.

Python
2 + 2
Exercise 2

Print the numbers 0, 1 and 2, each on its own line, using a loop.

Python
# loop three times
Exercise 3

Print the word run followed by the loop number, for the numbers 0 to 2.

Python
for i in range(3):
    # print run and the number
    pass