Programming · Standard Data Types
up to +100 XP
Stop 2.1 · Programming · 3 min

Standard Data Types

Master the fundamental building blocks of programming

Learning objectives:
  • Know the definition, purpose and use of integer, float, string and Boolean (2.1.1)

The four standard data types

A data type tells the program what kind of value is stored, which operations make sense and how much space it needs.

Data typeDefinitionPython exampleUse it for
Integer (int)A whole number, positive, negative or zeroage = 17Counts, quantities, scores
Float (float)A number with a decimal partprice = 4.99Money, measurements, averages
String (str)A sequence of characters in quotesname = "Amina"Names, text, codes such as postcodes or phone numbers
Boolean (bool)Either True or Falselogged_in = TrueYes/no states, flags, conditions

Choosing the right type

quantity = 3          # integer
unit_price = 2.50     # float
product = "Pen"       # string
in_stock = True       # Boolean
total = quantity * unit_price
print(product, total) # Pen 7.5
input() always returns a string. To do maths with it you must convert it, which is covered in stop 2.2.
Quick check · 10 questions

Check what stuck.

+10 XP each
Question 1

Question 1 of 10

Which data type stores a whole number?

Question 2

Question 2 of 10

Which data type is best for a price such as 4.99?

Question 3

Question 3 of 10

Which data type can only be True or False?

Question 4

Question 4 of 10

Why should a phone number like 07700 900123 be stored as a string?

Question 5

Question 5 of 10

What is the data type of "42" in Python?

Question 6

Question 6 of 10

What data type does input() always return?

Question 7

Question 7 of 10

Which value is a float?

Question 8

Question 8 of 10

Which would be the best data type to record whether a customer has paid?

Question 9

Question 9 of 10 · Match the pairs

Match each value to its data type.

42
3.14
"hello"
True
Question 10

Question 10 of 10 · Fill in the blanks

A whole number is an . A number with a decimal part is a .