Chapters
Python114 chapters

Exercises

Math

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

Exercise 1

Print floor, ceil and round of 3.7, in that order.

Python
import math
# three lines
Exercise 2

Print the mean and median of the values using the statistics module.

Python
values = [2, 4, 4, 4, 5, 5, 7, 9]
# print mean then median
Exercise 3

Adding the two decimals gives a float error. Print exactly 0.30 using Decimal.

Python
print(0.1 + 0.2)
# now print 0.30 exactly