Lesson 3 Data Types in Text-Based Programs
Lesson 3 Data Types in Text-Based Programs
LESSON 3:
DATA TYPES IN TEXT-BASED PROGRAMS
LEARNING OBJECTIVES
What is a string?
Answer: one or more characters that can include letters, symbols and numbers that
are not used in mathematics calculations, such as telephone numbers or credit card
numbers.
Identify the most appropriate data type
for each
Data Description Data type
Purple colour String
23 Age Integer
22.5 The price of the game Real/Float
True The result from 10>5 Boolean
001182738 the ID number of the String
book
Integer data types cannot start with a 0. Any leading 0s will be removed.
Therefore, any integer that needs to have leading 0s, such as an ID number,
will need to be stored as a string. In this table, if the ID number of the book
was stored as an integer, it would be 1182738, which might be the ID number
of a different book.
BOOLEAN DATA
if result == True:
print("Yes you entered True")
else:
print("Oh no, you did not enter True")
Design a questionnaire and write a program to ask
the user the questions and store their answers.