⬅ Previous TopicPython Constants
Next Topic ⮕Python Strings










Python Data Types
Data Types
In Python, data comes in different types. Just like in real life, where you have different kinds of things — like numbers, words, and yes/no answers — Python also needs to know what kind of data you're using.
Python uses data types to decide what you can do with the data. For example, you can add two numbers, but you can’t add a number to a word directly.
Common Data Types in Python
Here are some of the most common data types you'll use in Python language:
- int – whole numbers (like
5
,-2
,100
) - float – decimal numbers (like
3.14
,-0.5
,2.0
) - str – text, also called a “string” (like
"Hello"
,"Python"
) - bool – True or False (used for yes/no decisions)
Examples
number = 10 # int
pi = 3.14 # float
name = "Alice" # str
is_happy = True # bool
How to Check the Data Type
You can use the type() function to see what kind of data something is:
print(type(10)) # <class 'int'>
print(type("Hi")) # <class 'str'>
print(type(3.5)) # <class 'float'>
print(type(False)) # <class 'bool'>
Conclusion
Every value in Python has a type. Understanding these basic data types will help you store, use, and work with information in your programs.