📆 Day 2: Python Basics - Variables & Data Types
Store data like a pro!
---
📦 What are Variables?
Variables = Containers for storing data
Example output:
---
📝 Variable Rules
1. 🚫 Never starts with numbers/symbols (except
2. 🔠 Case-sensitive:
3. ✅ Allowed: letters, numbers, underscores
Good:
Bad:
---
🔤 Data Type Zoo
| Type | Example | Use Case |
|------------ |-----------------—-|------------------------———--|
|
|
|
|
Check types with:
---
🎯 Pro Tips
1. Swap variables without temp:
2. Assign multiple values:
---
💻 Practice Time
1. Profile Maker
2. Advanced Swap Challenge
Swap values without using a 3rd variable (Hint: Use math!)
Starting values:
---
🎯 Today's Goal
- Create variables confidently ✅
- Name them properly 🏷
- Understand 4 core data types 🔤
💬 *Stuck? Drop your code in comments!*
#PythonForBeginners #LearnToCode #Day2
Store data like a pro!
---
📦 What are Variables?
Variables = Containers for storing data
python
name = "Neo" # Text in quotes
age = 30 # Whole number
height = 6.1 # Decimal number
Example output:
Neo
, 30
, 6.1
---
📝 Variable Rules
1. 🚫 Never starts with numbers/symbols (except
_
) 2. 🔠 Case-sensitive:
Age ≠ age ≠ AGE
3. ✅ Allowed: letters, numbers, underscores
Good:
user_name
, price2
Bad:
2nd_user
, my-name
---
🔤 Data Type Zoo
| Type | Example | Use Case |
|------------ |-----------------—-|------------------------———--|
|
str
| "Hello"
| Text data | |
int
| 25
| Ages, counts | |
float
| 3.14
| Measurements, prices | |
bool
| True
/False
| Switches, conditions | Check types with:
python
print(type("Python")) # Output: <class 'str'>
---
🎯 Pro Tips
1. Swap variables without temp:
python
a, b = 5, 10
a, b = b, a # Magic!
2. Assign multiple values:
python
x, y, z = 10, 20, 30
---
💻 Practice Time
1. Profile Maker
python
name = "Your Name"
age = your_age
height = your_height
# Print all in one message
2. Advanced Swap Challenge
Swap values without using a 3rd variable (Hint: Use math!)
Starting values:
a = 5
, b = 10
---
🎯 Today's Goal
- Create variables confidently ✅
- Name them properly 🏷
- Understand 4 core data types 🔤
💬 *Stuck? Drop your code in comments!*
#PythonForBeginners #LearnToCode #Day2