Numeric data: floating point

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

Numeric data: floating point

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which value is a floating point number?
A 1.75
B 175
2. A student records their height as 1.68 metres. Which data type suits this value best?
A Floating point
B Integer
3. Which statement about integers and floating point numbers is correct?
A An integer has a decimal part, but a floating point number does not
B An integer has no decimal part, but a floating point number does
4. A canteen stores the price of a sandwich as $4.50. Which data type is the better choice?
A Integer
B Floating point
5. Which value is NOT a floating point number?
A 42
B 42.0

Match the Pairs

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

Left columnRight column
1height = 1.75 AA comma is used instead of a decimal point, so the value is not a valid floating point number. It should be 19.95.
2price = 19.95 BStores a money amount as a floating point number with 2 decimal places
3An integer is a whole number with no decimal part, unlike a floating point number CStores a floating point number, because the value has a decimal part
4Floating point numbers suit measurements that are not always whole numbers, such as a person's height in metres D175 has no decimal part, so it is an integer. A height in metres stored as a float should be written like 1.75.
5price = 19,95 Eheight = 1.62
6height = 175 (stored as a float, in metres) Fstudents = 28

Definitions

float

Fill in the Blanks

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

1.
price = _____("19.95") print(price + 0.05)
2.
price = 19.9567 print(round(price, _)) # 19.96
3.
height = 1.82 print(type(______)) # <class 'float'>
4.
age = 16 print(isinstance(age, ___))
5.
weight = 62.5 print(isinstance(weight, _____))

Spot the Error

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

Question 1
A item = 'Cap'
B qty = 2
C price = 19,95
Question 2
A price = 4.50
B total = price * '3'
C print(total)
Question 3
A temp = '36.6'
B limit = 37.5
C if temp > limit:
D print('Fever')
Question 4
A speed = 12.3456
B rounded = round(speed, 1.0)
C print(rounded)
Question 5
A total = 7
B share = total // 2
C print(share)

Answer Key

Numeric data: floating point
Section A: Quick Questions
Q1
A — 1.75
Q2
A — Floating point
Q3
B — An integer has no decimal part, but a floating point number does
Q4
B — Floating point
Q5
A — 42
Section B: Match the Pairs
Q1
height = 1.75 → Stores a floating point number, because the value has a decimal part
Q2
price = 19.95 → Stores a money amount as a floating point number with 2 decimal places
Q3
An integer is a whole number with no decimal part, unlike a floating point number → students = 28
Q4
Floating point numbers suit measurements that are not always whole numbers, such as a person's height in metres → height = 1.62
Q5
price = 19,95 → A comma is used instead of a decimal point, so the value is not a valid floating point number. It should be 19.95.
Q6
height = 175 (stored as a float, in metres) → 175 has no decimal part, so it is an integer. A height in metres stored as a float should be written like 1.75.
Section C: Definitions
Q1
float — A floating point number is a number with a decimal part, such as 1.75 or 19.95. It is used for measurements like height and for money, unlike an integer, which has no decimals.
Section D: Fill in the Blanks
Q1
price = float("19.95") print(price + 0.05)
Q2
price = 19.9567 print(round(price, 2)) # 19.96
Q3
height = 1.82 print(type(height)) # <class 'float'>
Q4
age = 16 print(isinstance(age, int))
Q5
weight = 62.5 print(isinstance(weight, float))
Section E: Spot the Error
Q1
C — A floating point number uses a full stop as its decimal point, not a comma. It should be price = 19.95.
Q2
B — The 3 is in quotes, so it is text, not a number. A float cannot be multiplied by text. It should be total = price * 3.
Q3
A — Quotes make 36.6 a string, not a floating point number, so it can't be compared with the float limit. It should be temp = 36.6.
Q4
B — The number of decimal places must be a whole number (an integer), not a float. It should be round(speed, 1).
Q5
B — // gives a whole number (3) and drops the decimal part. Use / to get the floating point answer 3.5.