Python Basics #2 🐍🔥
In the previous article of this Python Basics series, we learned about variables and how Python stores information in memory.
But here’s the thing:
Python doesn’t just store one kind of information.
Sometimes you want to store:
- Numbers
- Decimal values
- Text
- True/False conditions
- Collections of data
- And much more
To handle all of this properly, Python uses something called data types.
Understanding data types is one of the most important steps in becoming comfortable with programming.
And once you truly understand them, writing code becomes way less confusing.
So today, let’s break down Python data types in the simplest way possible — with examples ⚔️
What Is a Data Type?
A data type tells Python what kind of information a variable is storing.
Think of it like character classes in an RPG game.
Different characters have different abilities:
- A swordsman attacks differently
- A mage uses magic
- A healer restores health
Similarly, different data types behave differently in Python.
For example:
power_level = 9000
Python understands this is a number.
But here:
anime_name = "Dragon Ball"
Python understands this is text.
The data type helps Python decide:
- What operations are allowed
- How memory should be used
- How the data should behave
The Main Data Types Beginners Should Know
Today we’ll focus on three important beginner-friendly data types:
- Integers (
int) - Floating-point numbers (
float) - Boolean values (
bool)
These are used everywhere in Python projects.
1. Integers (int) 🔢
An integer is a whole number with no decimal point.
Examples:
episodes = 1000
score = 95
age = 17
All of these are integers.
Integers can be:
- Positive
- Negative
- Zero
Example:
health = 100
enemy_damage = -25
coins = 0
Example 🎌
Imagine you're creating an anime fighting game.
naruto_clones = 2000
Since shadow clones are counted as whole numbers, Python stores this as an integer.
You can perform calculations with integers too.
goku_power = 9000
goku_power = goku_power + 5000
print(goku_power)
Output:
14000
This is how games and apps constantly update values internally.
Why Integers Matter
Integers are commonly used for:
- Scores
- Health points
- Ages
- Inventory counts
- Likes on social media
- Followers
- Levels in games
Basically, whenever you need whole numbers, integers are usually the answer.
2. Floating-Point Numbers (float) 🌊
A floating-point number (or simply a float) is a number that contains a decimal point.
Examples:
pi = 3.14
rating = 9.8
temperature = 36.5
Unlike integers, floats can store fractional values.
Why Are They Called “Floating-Point”?
The decimal point can “float” to different positions.
For example:
1.5
10.75
999.999
0.0001
The decimal point moves around depending on the number.
That’s why they’re called floating-point numbers.
Example ⚡
Imagine tracking a character’s speed multiplier.
speed_multiplier = 1.75
Or maybe an anime rating app:
demon_slayer_rating = 9.4
Floats are perfect for precise values.
Integer vs Float
Let’s compare them side-by-side.
| Integer | Float |
|---|---|
7 |
7.0 |
100 |
100.5 |
-3 |
-3.14 |
Even though 7 and 7.0 look similar, Python treats them differently.
Checking Data Types in Python
Python provides a very useful function called type().
Example:
power_level = 9000
print(type(power_level))
Output:
<class 'int'>
Now with a float:
rating = 9.7
print(type(rating))
Output:
<class 'float'>
This is extremely useful when debugging programs.
3. Boolean Values (bool) ✅❌
A Boolean variable can only store one of two values:
TrueFalse
That’s it.
Nothing in between.
Real-Life Example
Think about simple yes/no situations:
- Is the player alive?
- Has the mission been completed?
- Is the villain defeated?
- Is the account verified?
All of these can be represented using Booleans.
Example 🎭
is_hokage = True
Or:
is_akatsuki_member = False
Booleans are heavily used in decision-making systems.
Why Booleans Are So Important
Booleans power the logic behind applications.
For example:
is_logged_in = True
if is_logged_in:
print("Welcome back!")
Output:
Welcome back!
This is how apps decide what should happen next.
Important Note About Boolean Values
In Python:
True
False
must start with capital letters.
Wrong:
true
false
Correct:
True
False
Python is case-sensitive.
Combining Data Types Together
Real programs usually use multiple data types together.
Example:
character_name = "Luffy"
bounty = 3000000000
pirate_king_candidate = True
power_multiplier = 1.8
Here we have:
| Variable | Data Type |
|---|---|
character_name |
String |
bounty |
Integer |
pirate_king_candidate |
Boolean |
power_multiplier |
Float |
This is how real applications organize information.
Beginner Mistakes to Avoid 🚨
1. Mixing Up Strings and Numbers
Wrong:
power = "9000" + 1000
This causes an error because "9000" is text, not a number.
Correct:
power = 9000 + 1000
2. Forgetting Decimal Points
rating = 9
This is an integer.
But:
rating = 9.0
This is a float.
Tiny difference.
Big meaning.
3. Using Quotes Around Boolean Values
Wrong:
is_alive = "True"
This becomes text, not a Boolean.
Correct:
is_alive = True
Fun Mini Project 🎮
Let’s create a tiny anime character profile.
character_name = "Gojo"
age = 28
power_level = 9999
cursed_energy_multiplier = 2.5
is_strongest_sorcerer = True
print(character_name)
print(age)
print(power_level)
print(cursed_energy_multiplier)
print(is_strongest_sorcerer)
Output:
Gojo
28
9999
2.5
True
Simple.
But this is already how real applications begin.
Quick Summary 🧠
| Data Type | Example | Purpose |
|---|---|---|
Integer (int) |
100 |
Whole numbers |
Float (float) |
9.5 |
Decimal numbers |
Boolean (bool) |
True |
True/False logic |
Final Thoughts
Understanding data types is a huge step in learning Python.
At first, they may seem small and unimportant.
But almost every Python program depends on them.
Games.
Web apps.
AI systems.
Automation scripts.
Data science projects.
Everything uses data types.
So spend time practicing them.
Create weird variables.
Experiment with anime examples.
Break things.
Fix things.
That’s how real learning happens.
Practice Challenge ⚔️
Try creating variables for:
- Your favorite anime
- Its rating
- Number of episodes
- Whether it is completed or ongoing
Example:
anime_name = "Attack on Titan"
rating = 9.9
episodes = 89
is_completed = True
Then use type() on each variable to see what Python says.
Wrapping Up
This is article #2 in the Python Basics series.
In the next article, we’ll explore:
👉 Strings in Python
👉 String operations
👉 Concatenation
👉 Useful string methods
👉 Common beginner mistakes
Stay tuned 🐍✨
Happy coding!
Top comments (0)