Discover what Python data means and what it can do.
A game stores different kinds of information for different jobs.
Reveal each stat and decide what kind of value it needs.
Can you be Level 15.5? Why must this be a whole number?
Wait, 1x damage is normal, but 2x is too much. How do we store that precise 1.5x boost?
Only "Yes" or "No". Do we need a number for this status?
A type describes what kind of value Python is working with.
int
Whole numbers such as 8, 0, and -12.
float
Numbers with a decimal point, such as 3.5.
str
Text enclosed in matching quotes.
bool
Exactly True or False, with capital letters.
Punctuation changes how Python understands a value.
int
A whole-number value.
float
A decimal-number value.
str
A one-character text value.
bool or str?
True is a boolean. Quotes turn "True" into text.
Name the type of this value before revealing the answer.
Name the type of this value before revealing the answer.
Name the type of this value before revealing the answer.
Name the type of this value before revealing the answer.
A literal is written directly; an expression is evaluated to produce a value.
42
Literal
42 is written directly, so Python can use that value immediately.
3 + 4
Expression
Python evaluates 3 + 4 to produce the value 7.
Python evaluates each expression before print() displays its result.
Write both the result and its type.
Write both the result and its type.
Write both the result and its type.
The types on both sides determine what + does.
3 + 4
Numeric Addition
Two numbers combine mathematically to produce 7.
"3" + "4"
String Concatenation
Two strings join in order to produce "34".
Predict the exact output. Use the quotes as evidence.
type() reports the kind of value Python sees.
type(3.5)
A Type Detective
Use type() after making a prediction, then compare the evidence with your idea.
The displayed class name confirms each value's type.
What happens when Python runs this line?
Complete it on time and submit it before the deadline.
Key takeaways from this lesson.
Values
Literals and expressions produce values.
Types
int, float, str, and bool describe different kinds of values.
Test
Predict first, then run and use type() to verify.
Write int, float, str, or bool beside each value.
1. Classify all twelve values as int, float, str, or bool.
8 8.0 "8" True -3 0.25 "False" False 0 -2.5 "3.0" "Python"
Predict first, then run each expression to check.
1. Write the resulting value and type for every line.
2. Run the code and correct any prediction that differs.
Create one clear example of every type.
1. Write four print() calls: one int, one float, one str, and one bool.
2. Make the four displayed values visibly different.
3. Run the program and check the output.
Use evidence to compare values that look similar.
1. Predict the type of each supplied value.
2. Use type() to test every prediction.
3. Write one sentence explaining why 5, 5.0, and "5" differ.
Decide the intended result before changing the code.
1. Run the broken line and read the error.
2. Repair it once to produce the number 79.
3. Repair it a different way to produce the text 709.
4. Explain how changing the types changed the behavior of +.