In Python, variables are used to store information that can be reused and manipulated throughout a program. Python is a dynamically typed language, which means you do not need to declare the data type of a variable explicitly — Python figures it out at runtime.
Below are some of the most commonly used data types in Python:
-
Integer (
int)
Whole numbers without decimal points.
Examples:10,-5 -
Float (
float)
Numbers with decimal points.
Examples:3.14,-0.001 -
String (
str)
Sequence of characters enclosed in single or double quotes.
Examples:"Hello",'Python' -
Boolean (
bool)
Represents truth values used in logic and conditions.
Values:True,False -
List (
list)
An ordered, mutable collection of items.
Example:[1, 2, 3] -
Dictionary (
dict)
A collection of key–value pairs.
Example:{"name": "Alice", "age": 25} -
NoneType (
None)
Represents the absence of a value or a null value.
Example:None
To check the data type of a variable, you can use the built-in type() function:
# Examples of variable types
x = 10 # Integer
y = 3.14 # Float
name = "Alice" # String
is_active = True # Boolean
fruits = ["apple", "banana", "cherry"] # List
person = {"name": "Alice", "age": 25} # Dictionary
nothing = None # NoneType
# Using variables
print(f"{name} has {x} apples.")
print(f"The value of pi is approximately {y}")
print(f"Active user? {is_active}")
print(f"Fruit list: {fruits}")
print(f"Person info: {person}")
print(f"Nothing is assigned: {nothing}")
# Checking data types
print(type(x)) #
print(type(y)) #
print(type(name)) #
print(type(is_active)) #
print(type(fruits)) #
print(type(person)) #
print(type(nothing)) #




