Exercises
Get Started
3 tasks. Write the code, press Check, and the page runs it against a real Python interpreter.
Exercise 1Passed
A file needs print() to show anything. Make this print 4 rather than computing it silently.
Python
2 + 2Wrap the expression in print().
print(2 + 2)Exercise 2Passed
Print the numbers 0, 1 and 2, each on its own line, using a loop.
Python
# loop three times
range(3) gives 0, 1 and 2.
for i in range(3):
print(i)Exercise 3Passed
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
passprint takes several arguments and puts a space between them.
for i in range(3):
print("run", i)