The use of data types
2.2.2 Data Types
Practise exam questionsData Types — Note 1 of 2
Integer, Real/Float, Boolean, Character and String
A data type defines what kind of data a variable can hold and what operations can be performed on it. The five main data types are integer (whole numbers), real/float (decimals), Boolean (True/False), character (a single symbol), and string (a sequence of characters). Choosing the correct data type ensures efficient storage and correct processing.
DoorActiveTime = 100.True or False; used for conditions, logic, and flags (e.g. DoorSensorActive, SystemArmed).123 as an integer and "123" as a string are different; they are stored and used differently.int, float, str and bool. In exam answers use the full names: integer, real (or float), string, Boolean and character.Exam tipCommon mistake
A classification that defines what kind of data a variable can store and what operations can be performed on it.
teamName → String, yearGroup → Integer, javelinThrow → Real/Float.A number with a decimal/fractional part, e.g. 3.14, -0.5. Use for measurements like javelinThrow = 18.2.
True/False). If there are 3+ options (win/loss/draw), Boolean is NOT suitable — use String or Integer.EmergencyPhoneNumber → String, UserName → String, DoorSensorActive → Boolean, DoorActiveTime → Integer.age = 16 # Integer
height = 1.75 # Float (real)
passed = True # Boolean
grade = "A" # String
initial = "J" # String (Python has no char type)
print(type(age)) # <class 'int'>
print(type(height)) # <class 'float'>
print(type(passed)) # <class 'bool'>Ready to test yourself?
Practise 2.2.2 questions