A variable is a named box holding a value: price = 5000 means the box called price holds the number 5000.
The key value types:
- int (whole number):
quantity = 25 - float (decimal):
rate = 4100.5 - str (text):
province = "សៀមរាប"— in quotes - bool (true/false):
in_stock = True
Operators: + - * / work like arithmetic. // gives the whole-part of division, % the remainder.
price_khr = 20000 rate = 4100 price_usd = price_khr / rate # ~4.88 name = "ម្ហូបក្រៀម" print(name, price_usd)
Naming rules: short and meaningful — price_khr beats x. Python is case-sensitive: Price and price differ.
Takeaways:
- Variable = a named box holding a value
- int, float, str, bool — the basic value types
- Short meaningful names make code readable