The math module

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

The math module

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which line loads Python's math module so you can use math.sqrt()?
A import math
B include math
2. What does math.sqrt(49) return?
A 24.5
B 7.0
3. After import math, which is the correct way to call the square root function?
A math.sqrt(25)
B sqrt(25)
4. What is math.pi?
A A function you call as math.pi()
B A constant, about 3.14159, written without brackets
5. What does math.ceil(4.2) return?
A 5
B 4

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1math.sqrt(49) AThe math. prefix is missing. After import math, the function must be called as math.sqrt(25).
2math.ceil(4.2) Barea = math.pi * r ** 2
3Import the math module first so its functions and constants can be used Cimport math
4Use the math module's built-in constant for pi to find the area of a circle Dmath.floor() rounds down, so it gives 7, not 8. Use math.ceil() to round up to 8.
5sqrt(25) ERounds 4.2 up to the next whole number, 5
6print(math.floor(7.9)) # expects 8 FReturns the square root of 49, which is 7.0

Definitions

import math

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
______ math print(math.sqrt(49))
2.
import math root = math.____(64) print(root)
3.
import math area = _______ * 5 ** 2 print(area)
4.
import math pages = math.____(23 / 10) print(pages)
5.
import math whole = math._____(7.9) print(whole)

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A import math
B root = sqrt(49)
C print(root)
Question 2
A import math
B r = 5
C area = math.pi * r ** 2
D print(Area)
Question 3
A import math
B n = math.cieling(4.2)
C print(n)
Question 4
A import maths
B x = math.floor(7.8)
C print(x)
Question 5
A import math
B side = 16
C root = math.sqrt[side]
D print(root)

Answer Key

The math module
Section A: Quick Questions
Q1
A — import math
Q2
B — 7.0
Q3
A — math.sqrt(25)
Q4
B — A constant, about 3.14159, written without brackets
Q5
A — 5
Section B: Match the Pairs
Q1
math.sqrt(49) → Returns the square root of 49, which is 7.0
Q2
math.ceil(4.2) → Rounds 4.2 up to the next whole number, 5
Q3
Import the math module first so its functions and constants can be used → import math
Q4
Use the math module's built-in constant for pi to find the area of a circle → area = math.pi * r ** 2
Q5
sqrt(25) → The math. prefix is missing. After import math, the function must be called as math.sqrt(25).
Q6
print(math.floor(7.9)) # expects 8 → math.floor() rounds down, so it gives 7, not 8. Use math.ceil() to round up to 8.
Section C: Definitions
Q1
import math — Loads Python's math module, giving you extras like math.sqrt(), math.pi, math.ceil() and math.floor() that basic operators don't have. Call them with the math. prefix.
Section D: Fill in the Blanks
Q1
import math print(math.sqrt(49))
Q2
import math root = math.sqrt(64) print(root)
Q3
import math area = math.pi * 5 ** 2 print(area)
Q4
import math pages = math.ceil(23 / 10) print(pages)
Q5
import math whole = math.floor(7.9) print(whole)
Section E: Spot the Error
Q1
B — After import math, sqrt() must be called with the math. prefix. It should be math.sqrt(49).
Q2
D — Python is case-sensitive. The variable is called area, not Area, so this would cause a NameError. It should be print(area).
Q3
B — The function name is misspelt. The math module's round-up function is math.ceil(), so it should be n = math.ceil(4.2).
Q4
A — The module is called math, not maths. Importing maths causes a ModuleNotFoundError. It should be import math.
Q5
C — Functions are called with round brackets, not square brackets. It should be math.sqrt(side).