← Back to module
Lesson 4 of 10
Every value in Python has a type, which tells Python (and you) what kind of data it is and what you can do with it. Module 1 mostly deals with four fundamental types.
int — whole numbers
age = 25
year = 2026
print(age, year)
float — decimal numbers
price = 9.99
pi = 3.14159
print(price, pi)
str — text ("string")
Strings are sequences of characters, wrapped in either single '...' or double "..." quotes —
both work the same in Python, just be consistent.
greeting = "Hello"
name = 'Ada'
print(greeting, name)
bool — True or False
Booleans represent one of exactly two values: True or False (capitalized, no quotes — they're
not strings). They're the backbone of decision-making in code, which you'll use heavily in
Module 2.
is_raining = True
is_sunny = False
print(is_raining, is_sunny)
Checking a value's type
Python has a built-in function, type(), that tells you what type something is:
print(type(25))
print(type(9.99))
print(type("hello"))
print(type(True))
Try it yourself
Create one variable of each type — an int, a float, a str, and a bool — then print all
four of their types using type().
Checkpoint
int= whole numbers,float= decimal numbers.str= text, wrapped in quotes.bool=TrueorFalse.type(value)tells you a value's type.
Questions about this lesson
Log in to ask a question.