Basic Data Types

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

Basic Data Types

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. What type is "Alice"?
A String
B Integer
2. What type is 15?
A String
B Integer
3. What type is 5.5?
A Float
B Integer
4. Which is a string?
A "100"
B 100
5. What type is 42?
A Float
B Integer

Match the Pairs

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

Left columnRight column
1'25' + 1 AValid: float type
2year_born = 1989.0 BOutput: 3.14
3score = 4.5 CError: float value, not an int
4name = 'Alice' DError: Can't add str and int
5print(int('25')) EOk: str type
6print(float('3.14')) FOutput: 25

Definitions

name = "Alice"

Fill in the Blanks

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

1.
name = _______
2.
age = __
3.
height = ___
4.
score = ___("100")
5.
city = ___________

Spot the Error

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

Question 1
A name = "Alice"
B age = 15"
C print(age)
Question 2
A score = 100
B city = Melbourne
C print(city)
Question 3
A name = 'Bob'
B age = 12
C height = 5,8
Question 4
A name = 'Alice'
B score = 85
C total = score + name
D print(total)
Question 5
A name = 'Charlie'
B age = 15
C height = 5.8
D city = 'Melbourne
E print(name)

Answer Key

Basic Data Types
Section A: Quick Questions
Q1
A — String
Q2
B — Integer
Q3
A — Float
Q4
A — "100"
Q5
B — Integer
Section B: Match the Pairs
Q1
'25' + 1 → Error: Can't add str and int
Q2
year_born = 1989.0 → Error: float value, not an int
Q3
score = 4.5 → Valid: float type
Q4
name = 'Alice' → Ok: str type
Q5
print(int('25')) → Output: 25
Q6
print(float('3.14')) → Output: 3.14
Section C: Definitions
Q1
name = "Alice" — Strings are text in quotes.~~age = 15
Section D: Fill in the Blanks
Q1
name = "Alice"
Q2
age = 15
Q3
height = 5.5
Q4
score = int("100")
Q5
city = "Melbourne"
Section E: Spot the Error
Q1
B — Line 2 has a stray quote. Should be: age = 15
Q2
B — Line 2 is missing quotes. Should be: city = "Melbourne"
Q3
C — Line 3 uses a comma not a decimal point. Should be: height = 5.8
Q4
C — Line 3 tries to add an int and a string. score is an integer, name is a string -- they can't be added.
Q5
D — Line 4 is missing a closing quote