Import

Libraries contain additional functions to use in your programs. Before you can use a library, you must import it with the import keyword. Example of importing the math library and using its sqrt() function to calculate the square root of a number:
import math

number = 36
square_root = math.sqrt(number)
print(square_root)
# 6
Example of importing the random library and using its randint() function to generate a random number between 1 and 10:
import random

number = random.randint(1, 10)
print(number)
# random number between 1 and 10

Exercise 1 of 6

Write a line of code to import the random library.

Your code

Exercise 2 of 6

Write a line of code to import the math library.

Your code

Exercise 3 of 6

Fix the error by entering the missing line.
random_num = random.randint(1, 10)
print(f"Your random number is {random_num}")

Your code

Exercise 4 of 6

Fix the error by entering the missing line.
radius = 3
area = math.pi * math.pow(radius, 2)
print(f"The area is {area}")

Your code

Exercise 5 of 6

Fix the error by entering the missing line.
import math
radius = random.randint(5, 10)
area = math.pi * math.pow(radius, 2)
print(f"The area is {area}")

Your code

Exercise 6 of 6

Write code to print a random number between 50 and 100.

Your code