Data Types in Python define what type of value a variable can store.
For example:
A variable can store numbers, text, decimal values, or multiple values.
name = "Sathish"
age = 22
height = 5.7
Here:
- name → String
- age → Integer
- height → Float
Types of Data Types in Python:
Python has 8 main built-in data types, grouped into categories.
- Numeric Data Types:
Used to store numbers.
Data Type Meaning Example
int Whole numbers age = 22
float Decimal numbers price = 99.5
complex Complex numbers x = 2 + 3j
- String (str): Used to store text.
name = "Sathish"
print(name)
Output:
Sathish
- List (list):
Used to store multiple values. Lists are changeable.
fruits = ["Apple", "Banana", "Mango"]
print(fruits)
- Tuple (tuple):
Used to store multiple values. Tuples cannot be changed after creation.
colors = ("Red", "Green", "Blue")
print(colors)
- Set (set):
Used to store unique values (no duplicates).
numbers = {10, 20, 10, 30}
print(numbers)
Output:
{10, 20, 30}
- Dictionary (dict):
Used to store data in key-value pairs.
student = { "name": "Sathish", "age": 22}
print(student["name"])
Output:
Sathish
- Boolean (bool):
Stores only two values: True or False.
is_student = True
print(is_student)
- None (NoneType):
Represents no value or an empty value.
result = None
print(result)
Top comments (0)