Exercises
Modules
3 tasks. Write the code, press Check, and the page runs it against a real Python interpreter.
Exercise 1Passed
Import math and print pi and the square root of 16.
Python
# import and print
import math, then use math.pi and math.sqrt.
import math
print(math.pi)
print(math.sqrt(16))Exercise 2Passed
Import only sqrt from math, so it can be called without the module name.
Python
# import just sqrt
print(sqrt(9))from module import name.
from math import sqrt
print(sqrt(9))Exercise 3Passed
Use Counter from collections to print the two most common letters.
Python
# import Counter and use most_common
print(result)Counter("aabbbc").most_common(2) gives the top two.
from collections import Counter
result = Counter("aabbbc").most_common(2)
print(result)