Welcome back to our 30 day Python learning series if you missed part 1
Learn Python in 30 Days – Part 1: What is Python and How to Start (With Real-Life Analogies)
I recommend checking it out before jumping in. It gives you the foundation you need to understand today’s topic.
Now that you’ve dipped your toes into Python, it’s time to meet your best friend in programming – variables and data types.
Let’s break it all down like you’re learning from a friend – not a textbook.
What Is a Variable in Python?
Think of a variable as a container like a water bottle.
Just like a bottle holds water, juice, or milk-
A variable holds a value – like a number, a name, or even a list of items.
Python
bottle = "Water"
Here, bottle is the variable, and it stores the value “Water”.
You can change it anytime:
Python
bottle = "Juice"
Now the same bottle (variable) has juice instead of water.
Why Do We Use Variables?
To store and reuse information without repeating ourselves.
Let’s say you want to print a student’s name 10 times:
Without a variable, you’d have to write
Python
print("Amina")
print("Amina")
print("Amina")
# ....10 times 😩
But if you store the name in a variable:
Python
name = "Amina"
for i in range(10):
print(name)
Boom! You’ve printed it 10 times without repeating yourself like a parrot.🦜
Ain’t nobody got time to type “Amina” 10 times!
just throw it in a variable and loop it. Easy win 😎
What Are Data Types in Python?
Dats types tell Python what kind of data you’re storing in a variable. It’s like labelling your bottles: is it milk, water, or oil?
Here are the most common python data types:
Data Type | Example | Meaning |
String (str) | “hello” | words/letters (like names) |
Integer (int) | 12 | Whole numbers (like age, marks) |
Float (float) | 99.5 | Decimal numbers (like price, weight) |
Boolean (bool) | True or False | Yes/No logic (like “is student present?”) |
Let’s See All These in Action:
python
name = "Amina" # Strong
age = 20 # Integer
weight = 55.5 # Float
is_student = True # Boolean
These lines tell Python:
- name is a string of text
- age is a whole number
- weight is a number with decimals
- is_student is either true or false
Just like real life!🌍
You Can Reuse & Update Variable Anytime
python
marks = 85
marks = 90
print(marks) # Output will be 90
Just like replacing the water in a bottle with juice.
Tips to Remember:
- Variable names should be simple and clear: student_name, not sn123
- Python is case sensitive: Name and name are different
- Strings should always be inside quotes: “hello” or ‘hello’
Practice Time!
Try this in a python compiler like Replit – it works right in your browser, so no need to install anything.
Python
name = "Ali"
age = 18
height = 5.9
is_enrolled = True
print("Name", name)
print("Age", age)
print("Height", height)
print("Enrolled?", is_enrolled)
Now change the values and try again. You’re already coding! 😎
What’s Next?
In Part 3, we’ll explore Input and Output in Python – how to take user input and display results smartly.
Stick with me – you’re doing amazing!
And remember, consistency Beats speed💪
✅ Recap: What You Learned Today
- Variables = containers for values
- Data types = labels for the kind of value
- Real-life examples make it easier to understand
- Python syntax is simple – just practice a little daily