Quest 1 • Lesson 2
📦 Variables & Data Types
In Python, a variable is like a labeled box where you can store data. You can create a variable by giving it a name and assigning a value using the = sign.
"Variables store values that can be used and changed throughout your program."
variables.py
name = "Khurram"
age = 25
height = 5.9
is_student = True
print(name)
print(age)
print(height)
print(is_student)
age = 25
height = 5.9
is_student = True
print(name)
print(age)
print(height)
print(is_student)
🧠 Python Data Types
"Khurram"– String (str): text inside quotes.25– Integer (int): whole numbers.5.9– Float: numbers with a decimal point.True/False– Boolean (bool): True or False values.
Python automatically detects the data type based on the value you assign.
✨ Challenge: Personal Details
Create variables to store your city (string), zip code (integer), and temperature (float). Then print them.
city = "Rawalpindi"
zip_code = 54000
temp = 30.5
print(city)
print(zip_code)
print(temp)
🔍 Bonus: Check a Variable's Type
Use the built‑in type() function.
age = 25
print(type(age)) # Output: <class 'int'>
print(type(age)) # Output: <class 'int'>
❤️ Support Free Education
This course is 100% free. If it helps you, consider buying me a coffee.
☕ Buy Me a Coffee➡️ Ready for more?
Next lesson: Working with Numbers & Strings – operations and formatting.
Continue to Lesson 1.3 →(Coming soon – check back or buy Pro Pack for instant access)