Chapters
Python114 chapters

Exercises

Numbers

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

Exercise 1

Print how many whole times 3 goes into 17, and what is left over.

Python
total = 17
per_box = 3
# print full boxes, then the remainder
Exercise 2

0.1 + 0.2 does not equal 0.3 exactly. Print True by comparing them with a tolerance instead.

Python
# compare 0.1 + 0.2 with 0.3 safely
Exercise 3

Print every even number below 10, one per line, using the remainder operator.

Python
for n in range(10):
    # print n only when it is even
    pass