Course Content
ฟังก์ชัน
การสร้างและเรียกใช้ฟังก์ชัน, พารามิเตอร์และอาร์กิวเมนต์, ค่าที่ส่งกลับจากฟังก์ชัน
0/5
SIT325 การเขียนโปรแกรมคอมพิวเตอร์-Digital Skill Course Certification for Government Personnel

ในกรณีที่มีตัวดำเนินการหลายตัวในประโยคเดียวกัน ไพธอนจะดำเนินการตามลำดับความสำคัญดังนี้:

  1. **
  2. *, /, //, %
  3. +, -
  4. <, >, <=, >=, ==, !=
  5. not
  6. and
  7. or

ตัวอย่างการใช้ตัวดำเนินการ

Python
x = 10
y = 5

sum = x + y          # 15
difference = x - y   # 5
product = x * y      # 50
quotient = x / y    # 2.0
floor_division = x // y # 2
remainder = x % y    # 0

is_equal = x == y    # False
is_greater = x > y   # True

is_true = (x > 5) and (y < 10) # True