Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Preview

Standard data types

This is the first page of the lesson. Read it and have a go at the activities. The rest is in the full lesson.

40 minutes

Your phone is full of data

Look at your phone. It shows the time. It shows your battery. It shows your name.

Some of it is a number. Some of it is words. Some of it is a yes or no.

A program must know which is which. The kind of value is called its data type. A data type is the kind of thing a value is.

Key words

WordWhat it meansExample
Data typeThe kind of thing a value is.integer, float, string, Boolean
IntegerA whole number with no decimal point.42
FloatA number with a decimal point.2.50
StringText. It goes inside quote marks."hello"
BooleanOnly two values: True or False.True
VariableA name that holds a value.goals = 3
Decimal pointThe dot in a number like 2.50.2.50

The cells students fill in are left blank in this preview.

Whole numbers: integers

An integer is a whole number. It has no decimal point.

Use an integer to count things. Your team scored 3 goals. The bus has 40 seats. You cannot score 2.5 goals, so goals are integers.

Try it: an integer

Code: python
goals = 3
print(goals)
print(type(goals))

# Change 3 to 5 and press Run again.

Numbers with a point: floats

A float is a number with a decimal point.

Use a float for money, height and weight. A bus ticket costs 2.50. Your height is 1.75 metres. Both are floats.

Try it: a float

Code: python
fare = 2.5
print(fare)
print(type(fare))
print(fare * 2)

Use a dot

data-callouts.tip.label

Python uses a dot, not a comma. Write 2.5, not 2,5. Python also prints 5.0 for two tickets. That is still a float.

Quick check: integer or float?

Have a go

Quick check: integer or float?

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Your answers are marked here and are not kept. A college account keeps every student’s marks.

Text: strings

A string is text. Put it inside quote marks.

"Messi" is a string. So is "Leeds". A phone number is also a string, because you never add two phone numbers together. A bus route like "5A" is a string too.

The lesson goes on

10 more parts of this lesson are in the full curriculum, with the tasks, the final check and the labs. A college account gives your students all of it.