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
| Word | What it means | Example |
|---|---|---|
| Data type | The kind of thing a value is. It says what you can do with it. | integer, string, date |
| Integer | A whole number with no decimal point. | 16 |
| Real | A number with a decimal point. Python calls this a float. | 12.50 |
| Float | The Python name for a real number. | 1.75 |
| Character | One single letter, digit or symbol. | "S" |
| String | Text. It is a line of characters. | "Sam Brown" |
| Boolean | Only two values: True or False. | True |
| Date | A day in the calendar. The computer can work with it. | 14 June 2027 |
| Database | A place where a computer keeps data in an organised way. | The trip bookings |
| Blob | A 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 type | What it holds | Trip form example |
|---|---|---|
| Integer | A whole number | Age: 16, seats booked: 32 |
| Real (float) | A number with a decimal point | Price paid: 12.50 |
| Character | One letter or symbol | Group letter: B |
| String | Text | Name: Sam Brown |
| Boolean | True or False | Form signed: True |
| Date | A day in the calendar | Trip date: 14 June 2027 |
| Blob | A big file | Photo of the student |
The cells students fill in are left blank in this preview.
Try it: integer and real
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 questionsYour 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
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.