Numeric data: integer

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

Numeric data: integer

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which value is an integer?
A 25
B 25.5
2. Which data is best stored as an integer?
A The number of students in a class
B The average height of students in metres
3. True or false: -3 is an integer.
A False
B True
4. Which value is NOT an integer?
A 0
B 3.0 (written with a decimal part)
5. A school records how many laptops it owns. Which data type suits this?
A Integer
B Boolean

Match the Pairs

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

Left columnRight column
125 AA negative whole number, which is still an integer
2-3 BScoreChange (Integer) = -4
3A count of students in a class is stored in an integer field CWrong belief that integers must be positive. Integers can be negative, so -3 is valid.
4Integers can be negative, such as a change in score DNumStudents (Integer) = 28
5NumStudents (Integer) = 24.5 EA positive whole number with no decimal part, so it is an integer
6Balance (Integer) = -3 // Error: negatives not allowed FAn integer cannot have a decimal part. A count of students must be a whole number such as 24.

Definitions

integer

Fill in the Blanks

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

1.
print(isinstance(25, ___))
2.
whole = ___(7.9) print(whole)
3.
print(____(25))
4.
____________ = 25 print(num_students + 1)
5.
change = _3 print(type(change))

Spot the Error

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

Question 1
A DECLARE students AS INTEGER
B DECLARE absent AS INTEGER
C students ← 28.5
D absent ← 3
Question 2
A DECLARE goals AS FLOAT
B goals ← 3
C goals ← goals + 1
D DISPLAY goals
Question 3
A DECLARE total AS INTEGER
B total ← 1,200
C DISPLAY total
Question 4
A DECLARE tickets AS INTEGER
B tickets ← 0
C tickets ← tickets + 12
D DISPLAY "tickets"
Question 5
A Table: Class
B Field: ClassName, Text
C Field: StudentCount, Text
D Field: RoomNumber, Integer

Answer Key

Numeric data: integer
Section A: Quick Questions
Q1
A — 25
Q2
A — The number of students in a class
Q3
B — True
Q4
B — 3.0 (written with a decimal part)
Q5
A — Integer
Section B: Match the Pairs
Q1
25 → A positive whole number with no decimal part, so it is an integer
Q2
-3 → A negative whole number, which is still an integer
Q3
A count of students in a class is stored in an integer field → NumStudents (Integer) = 28
Q4
Integers can be negative, such as a change in score → ScoreChange (Integer) = -4
Q5
NumStudents (Integer) = 24.5 → An integer cannot have a decimal part. A count of students must be a whole number such as 24.
Q6
Balance (Integer) = -3 // Error: negatives not allowed → Wrong belief that integers must be positive. Integers can be negative, so -3 is valid.
Section C: Definitions
Q1
integer — A whole number with no decimal part, positive or negative, used for counts such as the number of students in a class (e.g. 25, 0 or -3).
Section D: Fill in the Blanks
Q1
print(isinstance(25, int))
Q2
whole = int(7.9) print(whole)
Q3
print(type(25))
Q4
num_students = 25 print(num_students + 1)
Q5
change = -3 print(type(change))
Section E: Spot the Error
Q1
C — An integer has no decimal part, and you cannot have half a student. The line should be students ← 28.
Q2
A — Goals are counted in whole numbers, so the variable should be declared AS INTEGER. FLOAT is for numbers with decimal places.
Q3
B — Integer values are typed without commas or other separators. It should be total ← 1200.
Q4
D — The quotes make this the text "tickets" instead of the integer stored in the variable. It should be DISPLAY tickets.
Q5
C — The number of students is a count, so the field should use the Integer data type, not Text. It should be Field: StudentCount, Integer.