python · level 1 · unit 3 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
Quotes turn a number into text.
Python sorts every value into a . Text in quotes is a string. A whole number with no quotes, like 12, is an . Same digits, different type, and Python treats them very differently.
Picture a front door with 12 painted on it, and a box of 12 eggs. The door number is a label you read, like "12". The eggs are an amount you can count and add, like 12.
Not sure which one you have? Ask type(). Its answer includes str for a string or int for an integer.
print(type("12"))
print(type(12))
print(12 + 12) A number inside quotes is text, even when it looks like a number.
guess first
What will the scoreboard show?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
home_goals = "2"
away_goals = "1"
print(home_goals + away_goals)
your turn
Your turn. How old will you be?
Type your age as a number, with no quotes, then press run.
fix it
These cookies will not add up. Can you fix them?
- The last line of the error says TypeError. Two values of different types are being mixed.
- Look at line 1. The quotes turn 4 into a string, but
bakedis an integer. - Remove the quotes so line 1 reads
cookies = 4, then press run.
nailed it
you can tell words from numbers. :D
- Quotes mean a string. No quotes mean a number.
- An integer is a whole number, like 7 or 120.
type()tells you what kind of value you have.
new words in your collection
- type
- integer
This lesson isn’t saved. A free account remembers every lesson you finish.