Python Variables and Data Types for Beginners
Learning Python is one of the smartest moves you can make in today’s digital world. Whether you’re looking to build websites, automate tasks, analyze data, or dive into artificial intelligence — Python is often the first language of choice. Why? Because it’s simple, readable, and beginner-friendly.
But where exactly should you begin?
If you’re just getting started, one of the first concepts you need to grasp is variables and data types. These are the foundation blocks of any programming language. You’ll use them in every Python program you ever write — from the simplest calculator to a full-blown web app.
In this beginner-friendly guide, I’ll walk you through everything you need to know about variables and data types in Python — explained clearly with examples, analogies, and a mini challenge at the end. Let’s take it step by step together.
What Are Variables in Python?
Think of variables as labelled boxes you can use to store information in your program. That “information” could be a number, a name, a list of items, or even a sentence. You label the box (the variable name), then place something inside (the value).
In Python, creating a variable is as simple as writing:
name = "Subtel"
age = 25
Here’s what’s happening:
name
is the variable name.=
assigns the value to it."Subtel"
is a string (text), and25
is an integer (number).
Python figures out what kind of data it is automatically — so you don’t have to tell it whether it’s text or a number. That makes it really beginner-friendly.
Why Do We Need Variables?
Variables allow us to:
- Store information
- Reuse values later
- Change values as the program runs
For example, let’s say you want to greet a user:
name = "Subtel"
print("Hello, " + name)
Instead of typing the name over and over, you store it in a variable and use that variable wherever you need it.
Python Data Types You Should Know First
In Python, every value has a type. These types are called data types. Let’s focus on four beginner-friendly types:
1. Strings – Text
A string is a piece of text — anything inside quotes. It could be a name, a sentence, or even numbers written as text.
name = "Subtel"
message = "Welcome to Python!"
2. Integers – Whole Numbers
Integers are numbers without decimal points.
age = 30
number_of_apples = -10
3. Floats – Decimal Numbers
A float is a number that has a decimal point.
temperature = 36.5
height = 5.9
4. Booleans – True or False
Booleans only have two possible values: True or False. These are great for yes/no decisions in your code.
is_student = True
has_paid = False
How to Check the Data Type of a Variable
Sometimes you may want to check what kind of data is stored in a variable. Python provides a built-in function called type() for this:
name = "Subtel"
print(type(name)) # Output: <class 'str'>
This helps you debug your code or confirm your data type is correct.
Reassigning Variables
You can change the value stored in a variable at any time. That’s the whole point — they’re called “variables” because they can vary.
mood = "happy"
mood = "tired"
You’ve just changed the value of mood
from “happy” to “tired”.
Naming Your Variables (Best Practices)
Python lets you name your variables almost anything, but some names are better than others. Here are a few tips:
- ✅ Use descriptive names
- ✅ Use lowercase with underscores
- ❌ Don’t use numbers first or special characters
- ❌ Avoid special characters like @, %, –
# Bad
1stName = "Subtel" # ❌
# Good
first_name = "Subtel" # ✅
Real-Life Analogy to Make It Stick
Your phone contacts work just like variables:
- The contact name is the variable
- The stored phone number is the value
If your friend changes their number, you just update the value (the number), but the name (variable) stays the same. That’s exactly how variables work!
Let’s Practice (Python Mini Challenge)
Try this in your editor:
- Create variables for your own name, age, and country.
- Print them using the print() function.
- Update your age by adding 1 to it.
my_name = "Subtel"
my_age = 25
my_country = "Nigeria"
print(my_name)
print(my_age)
print(my_country)
# Increase age by 1
my_age = my_age + 1
print("Next year, I'll be", my_age)
What’s Next?
Now that you understand variables and data types, it’s time to get hands-on.
➡️ Next: Build a Simple Budget Tracker with Python Variables
In the next post, I’ll walk you through a mini project using everything you’ve learned here. You’ll create a simple budget tracker that stores values, performs calculations, and prints results. See you there!
Need Help with a Python Assignment or Project?
Learning Python is exciting — but it can also get tricky sometimes. Whether you're stuck on a bug, running out of time on an assignment, or building something cool and just need a little help...
We’ve got your back. 💪
Our team is here to support you with:
- ✅ Python assignments & school projects
- ✅ Debugging errors or fixing code
- ✅ Custom scripts or mini tools
- ✅ Personal coding challenges or portfolio projects
Don’t struggle alone — reach out and let us help you get it done the smart way.
Let’s build something awesome together! Contact Us Now!