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

Preview

The seven common 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.

45 minutes

The school trip form

Your class is going on a trip. The booking form asks for six things.

Name. Age. Price paid. Has the form been signed? Date of the trip. A photo of the student.

Each one is a different kind of thing. You cannot add two names. You cannot sign a price. A computer must know the kind of each one. Today you learn the seven kinds.

Key words

WordWhat it meansExample
Data typeThe kind of thing a value is. It says what you can do with it.integer, string, date
IntegerA whole number with no decimal point.16
RealA number with a decimal point. Python calls this a float.12.50
FloatThe Python name for a real number.1.75
CharacterOne single letter, digit or symbol."S"
StringText. It is a line of characters."Sam Brown"
BooleanOnly two values: True or False.True
DateA day in the calendar. The computer can work with it.14 June 2027
DatabaseA place where a computer keeps data in an organised way.The trip bookings
BlobA big lump of data, such as a photo or a song. Blob means binary large object.photo.jpg

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

The seven types on the trip form

Data typeWhat it holdsTrip form example
IntegerA whole numberAge: 16, seats booked: 32
Real (float)A number with a decimal pointPrice paid: 12.50
CharacterOne letter or symbolGroup letter: B
StringTextName: Sam Brown
BooleanTrue or FalseForm signed: True
DateA day in the calendarTrip date: 14 June 2027
BlobA big filePhoto of the student

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

Try it: integer and real

Code: python
seats = 50
booked = 32
price = 12.5

print(seats - booked, type(seats - booked))
print(price * booked, type(price * booked))

# Change booked to 40 and run it again.

Quick check: integer or real?

Have a go

Quick check: integer or real?

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.

Characters and strings

A character is one single letter, digit or symbol. "S" is a character.

A string is a line of characters. "Sam Brown" is a string. Python has no separate character type. It uses a string of length 1.

Try it: characters and strings

Code: python
name = "Sam Brown"
print(name)
print(name[0])
print(len(name))

# name[0] is the first character.
# Change the name and run it again.

A phone number is a string

data-callouts.warning.label

Never use an integer for a phone number or a student number. You do not add them. And a number loses the zero at the start: 07700 becomes 7700. Use a string.

Boolean, date and blob

A Boolean is True or False. Use it for yes or no questions, such as "form signed?".

A date is a day in the calendar. Use a date type, not a string, because the computer can then count the days to the trip.

A blob is a big lump of data, such as a photo. A database keeps it as one object. You do not read the inside of it as text.

The lesson goes on

7 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.