A value has content and a type.
In the Variables lesson, you wrote age = 25: age is the name and 25 is the value. Now add one important idea: the value 25 has the type int. A useful mental model is value → type → behavior. The type helps Python decide how it can use and interpret a value.
age = 25 # value: 25, type: int
text_age = "25" # value: "25", type: strThese values look similar because both contain 2 and 5. But 25 is a number and "25" is text. Data types are not just labels to memorize: they affect what Python does with values.
25 → int → behaves like a number
"25" → str → behaves like textThink back to age = 25: age is the variable name, 25 is the value, and int is the value’s type. We are building on Variables, not starting over.
Why types matter: Python needs to know whether a value is a number, text, or a true/false state so it can handle the value in a useful way.
age = 25
temperature = -4
score = 0
year = 2026An int represents a whole number with no decimal part. It can be positive, negative, or zero. Ages, scores, years, and temperatures can all be integers when they have no decimal part.
price = 19.5
height = 1.82
temperature = -3.5A float is a number with a decimal part. In Python, write the decimal separator with a dot: 19.5, not a comma. Prices, measurements, and some temperatures often need a float.
name = "Ana"
city = "Novi Sad"
message = 'Hello'
text_age = "25"A str, short for string, represents text. Write simple strings inside single or double quotation marks. A string can contain letters, digits, spaces, and other characters — so "25" is text even though it looks like a number.
is_ready = True
is_logged_in = False
has_permission = TrueA bool, short for Boolean, represents a two-state idea such as yes/no, on/off, or ready/not ready. Python’s Boolean values are exactly True and False: no quotation marks and a capital first letter. True is a Boolean; "True" is a string. Later, Boolean values will help programs make decisions.
age = 25
print(type(age))
# <class 'int'>
print(type(25))
print(type("25"))
print(type(19.5))
print(type(True))Use type() to ask Python what type a value currently has. For now, read <class 'int'> as “Python says this value has type int.” We will learn later why Python uses the word class. The important part now is what type() checks, not memorizing this output format.
number = 25
text = "25"
print(type(number))
print(type(text))Quotation marks change how Python interprets the value. 25 has type int; "25" has type str. Values can look similar to us and still have different types in Python.
print(2 + 3)
print("2" + "3")The first line prints 5 because + adds two numbers. The second line prints 23 because + joins two strings. The same + symbol behaves differently because the values have different types.
name = "Ana"
age = 12
height = 1.55
is_student = Truename is a str, age is an int, height is a float, and is_student is a bool. Ask yourself: why would "12" usually be a worse choice for age if a program plans to calculate with it?
value = 10
print(type(value))
value = "ten"
print(type(value))Python allows the same variable name to later receive a value with a different type. The type belongs to the value currently assigned to the name. You may later hear this called dynamic typing, but you do not need that term yet. Clear, consistent variable names still make programs easier to understand.
age = "25" # text, not a number
is_ready = "True" # text, not a Boolean
price = 19.5 # use a dot for decimalsNone of these lines is necessarily a syntax error. But valid Python is not always the right way to represent the information. If you want to calculate with age, use 25, not "25". If you want a true/false state, use True, not "True".
product = "Notebook"
quantity = 3
price = 4.5
in_stock = TruePause and identify each value: Which one is a string? Which is an integer, a float, and a Boolean? What do you expect type(quantity) to report? Learning to recognize types while reading code is just as useful as running it.
