Different Kinds of Data
Programs don’t just store one kind of information.
Some information is text.
Some information is numbers.
Some information represents a yes or no decision.
Python needs to know what kind of data it is working with.
Some information is text.
Some information is numbers.
Some information represents a yes or no decision.
Python needs to know what kind of data it is working with.
Strings (Text)
If something is text, it must go inside quotation marks.
Example:
game_title = "World of Software Engineering"
If you use quotes, Python treats it as text.
If something is text, it must go inside quotation marks.
Example:
game_title = "World of Software Engineering"
If you use quotes, Python treats it as text.
Integers (Whole Numbers)
Whole numbers do NOT use quotation marks.
Example:
player_health = 100
If you put the number inside quotes, it becomes text instead of a number.
Whole numbers do NOT use quotation marks.
Example:
player_health = 100
If you put the number inside quotes, it becomes text instead of a number.
Booleans (True or False)
Sometimes we need a variable to answer a question.
Is the player a warrior class?
That answer can only be:
True
or
False
Example:
player_is_warrior = True
Important:
True and False do NOT use quotation marks.
Sometimes we need a variable to answer a question.
Is the player a warrior class?
That answer can only be:
True
or
False
Example:
player_is_warrior = True
Important:
True and False do NOT use quotation marks.
Your Task:
The code below contains mistakes.
• player_health must be stored as a number
• player_is_warrior must be stored as a Boolean value
Fix the code without changing anything else.
The code below contains mistakes.
• player_health must be stored as a number
• player_is_warrior must be stored as a Boolean value
Fix the code without changing anything else.
Fix the data types
player_health = "100"
player_is_warrior = "True"
# don't change the code under this comment
print(f"player_health is a/an {type(player_health)}")
print(f"player_is_warrior is a/an {type(player_is_warrior)}")