🐍 Lesson 11: Python Operators (Python အော်ပရေတာများ)
1. Operator ဆိုတာဘာလဲ?
မြန်မာ → Operator ဆိုတာ Variable တွေ၊ တန်ဖိုးတွေကို တွက်ချက်ဖို့ သုံးတဲ့ အမှတ်အသား (symbol) ဖြစ်တယ်။
English → An operator is a symbol used to perform operations on variables and values.
2. Python Operator အမျိုးအစားများ
(a) Arithmetic Operators → + - * / // % **
(b) Comparison Operators → == != > < >= <=
(c) Logical Operators → and or not
(d) Assignment Operators → = += -= *= /= %=
(e) Membership Operators → in, not in
(f) Identity Operators → is, is not
3. အကျဉ်းချုပ်
✅ Arithmetic → + - * / // % **
✅ Comparison → == != > < >= <=
✅ Logical → and or not
✅ Membership → in, not in
python
# ===== 1. Arithmetic Operators =====
x = 10
y = 3
print("===== Arithmetic =====")
print(f"x + y = {x + y}") # 13
print(f"x - y = {x - y}") # 7
print(f"x * y = {x * y}") # 30
print(f"x / y = {x / y}") # 3.333...
print(f"x // y = {x // y}") # 3 (Floor Division)
print(f"x % y = {x % y}") # 1 (Modulus)
print(f"x ** y = {x ** y}") # 1000 (Exponentiation)
# ===== 2. Comparison Operators =====
print(f"\n===== Comparison =====")
a = 5
b = 10
print(f"a == b: {a == b}") # False
print(f"a != b: {a != b}") # True
print(f"a > b: {a > b}") # False
print(f"a < b: {a < b}") # True
# ===== 3. Logical Operators =====
print(f"\n===== Logical =====")
print(f"True and False: {True and False}")
print(f"True or False: {True or False}")
print(f"not True: {not True}")
# ===== 4. Assignment Operators =====
print(f"\n===== Assignment =====")
c = 5
c += 3 # c = c + 3
print(f"c += 3: {c}") # 8
c *= 2 # c = c * 2
print(f"c *= 2: {c}") # 16
# ===== 5. Membership Operators =====
print(f"\n===== Membership =====")
fruits = ["apple", "banana"]
print(f"'apple' in fruits: {'apple' in fruits}")
print(f"'mango' not in fruits: {'mango' not in fruits}")You should see
===== Arithmetic ===== x + y = 13 x - y = 7 x * y = 30 x / y = 3.333... x // y = 3 x % y = 1 x ** y = 1000 ===== Comparison ===== a == b: False a != b: True a > b: False a < b: True ===== Logical ===== True and False: False True or False: True not True: False ===== Assignment ===== c += 3: 8 c *= 2: 16 ===== Membership ===== 'apple' in fruits: True 'mango' not in fruits: True