Thuta Learning
ရှာဖွေရန်
BasicProgrammingbeginner

Python Numbers

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

🐍 Lesson 7: Python Numbers (Python ကိန်းများ)

1. Numbers ဆိုတာဘာလဲ?

မြန်မာ → Python မှာ ကိန်းတွေကို သုံးတဲ့အခါ Data Type သုံးမျိုး အဓိကရှိတယ်။

English → In Python, numbers are mainly represented by three data types.

2. Number Types

  • int (Integer) → ကိန်းပြည့် (ဥပမာ 10, -5, 1000)
  • float (Floating point) → ဒဿမကိန်း (ဥပမာ 3.14, -0.5)
  • complex → ကိန်းစုံ (ဥပမာ 2 + 3j)

3. Arithmetic Operators (သင်္ချာအော်ပရေတာများ)

Python မှာ ကိန်းတွေနဲ့ တွက်ချက်ဖို့ အောက်ပါ operator တွေသုံးတယ်။

Operatorအဓိပ္ပာယ်ဥပမာResult
+ပေါင်း5 + 38
-နုတ်5 - 32
*မကြိမ်5 * 315
/Division (ဒဿမနဲ့)5 / 22.5
//Floor Division (အနိမ့်ဆုံးကိန်းပြည့်)5 // 22
%Modulus (ကျန်ရှိ)5 % 21
**Exponentiation (အနိပ်)2 ** 38

4. အကျဉ်းချုပ်

✅ Python Numbers → int, float, complex

✅ Arithmetic operators → + - * / // % **

✅ Casting နဲ့ function တွေသုံးပြီး ကိန်းတွေကို ပြောင်းနိုင်၊ တွက်နိုင်

python
# ===== 1. Number Types =====
x = 10        # int
y = 3.14      # float
z = 2 + 3j    # complex

print(f"Int: {x}, Type: {type(x)}")
print(f"Float: {y}, Type: {type(y)}")
print(f"Complex: {z}, Type: {type(z)}")

# ===== 2. Arithmetic Operations =====
a = 7
b = 3

print(f"\n===== Arithmetic Operators =====")
print(f"{a} + {b} = {a + b}")   # Addition
print(f"{a} - {b} = {a - b}")   # Subtraction
print(f"{a} * {b} = {a * b}")   # Multiplication
print(f"{a} / {b} = {a / b}")   # Division
print(f"{a} // {b} = {a // b}") # Floor Division
print(f"{a} % {b} = {a % b}")   # Modulus
print(f"{a} ** {b} = {a ** b}") # Exponentiation

# ===== 3. Type Conversion =====
print(f"\n===== Type Conversion =====")
num = 5
print(f"int to float: {float(num)}")   # 5.0
print(f"float to int: {int(3.99)}")     # 3

# ===== 4. Useful Functions =====
print(f"\n===== Useful Functions =====")
print(f"abs(-10) = {abs(-10)}")          # Absolute value
print(f"pow(2, 4) = {pow(2, 4)}")         # Power
print(f"round(3.14159, 2) = {round(3.14159, 2)}")  # Rounding
You should see
Int: 10, Type: Float: 3.14, Type: Complex: (2+3j), Type: ===== Arithmetic Operators ===== 7 + 3 = 10 7 - 3 = 4 7 * 3 = 21 7 / 3 = 2.333... 7 // 3 = 2 7 % 3 = 1 7 ** 3 = 343 ===== Type Conversion ===== int to float: 5.0 float to int: 3 ===== Useful Functions ===== abs(-10) = 10 pow(2, 4) = 16 round(3.14159, 2) = 3.14
Python Numbers | Thuta Learning