
📦 1. What is a Variable?
Short answer → A variable is like a memory box that ties a value to a name.
In other words → A variable is like a named box in memory that stores a value.
📝 2. Naming Rules for Variables
Short answer → It can't start with a number, can't use a keyword, and should have a meaningful name.
In other words → Cannot start with a number, cannot use Python keywords, should be meaningful.
✅ age = 25 - Correct
❌ 1name = "Sai" - Wrong (starts with number)
🎯 3. Variable Types / Data Types
- • int (whole number / integer) →
a = 10 - • float (decimal number) →
pi = 3.14 - • str (text / string) →
greet = "Hello" - • bool (true/false / boolean) →
is_active = True
💻 4. Using Variables
Variables are named memory locations that store data. Because Python uses Dynamic typing, it figures out a variable's type automatically.
Short answer → Variables can store values and be used to perform calculations.
In other words → Variables can store values and perform calculations.
📌 5. Summary
• Variable = a named memory box
• Assign with = sign → name = value
• Types: int, float, str, bool
• Dynamic typing - the type is figured out automatically
# ===== 1. Variable Declaration Examples =====
x = 5 # x ထဲမှာ 5 ကို သိမ်းထားတယ် / x stores the value 5
name = "Sai" # name ထဲမှာ "Sai" ဆိုတဲ့ စာသားကို သိမ်းထားတယ် / name stores the string "Sai"
print(f"x = {x}")
print(f"name = {name}")
# ===== 2. Variable Types Examples =====
# Different data types
age = 25 # int (ကိန်းပြည့် / integer)
height = 5.9 # float (ဒဿမကိန်း / decimal)
greet = "Hello" # str (စာသား / string)
is_student = True # bool (အမှန်/အမှား / boolean)
print(f"\nAge: {age}, Type: {type(age)}")
print(f"Height: {height}, Type: {type(height)}")
print(f"Greet: {greet}, Type: {type(greet)}")
print(f"Is Student: {is_student}, Type: {type(is_student)}")
# ===== 3. Using Variables in Calculations =====
a = 10
b = 20
sum_result = a + b
print(f"\na + b = {a} + {b} = {sum_result}")
# ===== 4. Variable Type Can Change (Dynamic Typing) =====
my_var = 42
print(f"\nInitial: my_var = {my_var}, Type: {type(my_var)}")
my_var = "Now I'm a string"
print(f"Changed: my_var = {my_var}, Type: {type(my_var)}")x = 5 name = Sai Age: 25, Type: Height: 5.9, Type: Greet: Hello, Type: Is Student: True, Type: a + b = 10 + 20 = 30 Initial: my_var = 42, Type: Changed: my_var = Now I'm a string, Type: