Python Lesson 3: Variables and Data Types
PYTHON
AllComputerss
4/18/20261 min read


Understanding variables and data types is one of the most important steps in learning Python. Variables allow you to store information that can be used and manipulated throughout your program, while data types define the kind of values those variables can hold.
What Are Variables?
A variable is essentially a name that refers to a value stored in memory. In Python, you don’t need to declare the type of a variable explicitly — Python figures it out based on the value you assign.
Example:
# Assigning values to variables
name = "Alice"
age = 25
height = 5.7
print(name)
print(age)
print(height)
Here, name is a variable holding a string, age holds an integer, and height holds a floating-point number.
Common Data Types in Python
Python supports several built-in data types. Here are the most common ones:
Integers (int): Whole numbers, positive or negative.
score = 100
Floating-Point Numbers (float): Numbers with decimals.
pi = 3.14159
Strings (str): Text enclosed in quotes.
greeting = "Hello, World!"
Booleans (bool): Logical values True or False.
is_active = True
Lists (list): Ordered collections of items.
fruits = ["apple", "banana", "cherry"]
Tuples (tuple): Immutable ordered collections.
coordinates = (10, 20)
Sets (set): Unordered collections of unique items.
unique_numbers = {1, 2, 3}
Dictionaries (dict): Key-value pairs.
person = {"name": "Alice", "age": 25}
Dynamic Typing
Python is dynamically typed, meaning you can reassign a variable to a different type without issue:
x = 10 # x is an integer
x = "ten" # now x is a string
Conclusion
Variables and data types form the foundation of Python programming. By mastering them, you’ll be able to store, manipulate, and organize data effectively. In the next lesson, we’ll explore operators, which allow you to perform calculations and comparisons with these variables.
© 2026 AllComputerss. All rights reserved.