Re: ทำความรู้จักกับภาษา python (20) : การ return (รีเทิน) ค่าออกจากฟังก์ชัน
โพสต์แล้ว: 10/08/2018 3:51 pm
การสร้างฟังก์ชั่น ส่งค่าออกจากฟังก์ชั่นไพทอน The return Statement:
ผลลัพธ์
โค้ด: เลือกทั้งหมด
total = 10
def myfucn1(arg1,arg2):
a = 15
total = arg1 + arg2
print("ตัวแปรภายในฟังก์ชัน :",a)
print("ตัวแปร total ที่อยู่ภายในฟังก์ชัน :", total)
return total
total = myfucn1(10,20)
print("ตัวแปร total ที่อยู่ภายนอกฟังก์ชัน :",total)