📝 Overview
In this lesson, you’ll learn how to store and manipulate data in Python using variables, understand different data types, and perform operations using arithmetic and logical operators.
🎯 What You’ll Learn
-
What variables are and how to use them
-
The different data types in Python
-
How to perform basic math and logic with operators
📦 1. What is a Variable?
A variable is a container used to store data. You create a variable by assigning a value to a name using the =
sign.
Here:
-
name
holds a string"Alex"
-
age
holds an integer20
🧠 2. Python Data Types
Data Type | Example | Description |
---|---|---|
int |
5 , 100 |
Whole numbers |
float |
3.14 , 1.0 |
Numbers with decimals |
str |
"Hello" |
Text or string |
bool |
True , False |
Boolean (yes/no) |
🧮 3. Operators in Python
➕ Arithmetic Operators
Operator | Meaning | Example |
---|---|---|
+ |
Addition | 5 + 3 → 8 |
- |
Subtraction | 9 - 2 → 7 |
* |
Multiplication | 3 * 4 → 12 |
/ |
Division | 10 / 2 → 5.0 |
** |
Exponent | 2 ** 3 → 8 |
🧮 Example:
🤔 Comparison Operators
Operator | Meaning |
---|---|
== |
Equal to |
!= |
Not equal to |
> |
Greater than |
< |
Less than |
>= |
Greater than or equal |
<= |
Less than or equal |
⚙️ Logical Operators
Operator | Meaning |
---|---|
and |
True if both are True |
or |
True if at least one is True |
not |
Reverses the result |
👨💻 Mini Practice
🧠 Quick Recap
-
Variables store data you want to use
-
Python has data types like
int
,float
,str
,bool
-
Operators let you perform math and comparisons
✅ Next Lesson Preview
→ Input & Output in Python