ทำความรู้จักกับภาษา python (16) : การสร้างฟังก์ชันโดยมี Default Value (ดีฟอลท์ เวลู่)

แชร์ความรู้ภาษา Python ไพทอน การเขียนโปรแกรมภาษาไพทอน

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
jirawoot
PHP VIP Members
PHP VIP Members
โพสต์: 3129
ลงทะเบียนเมื่อ: 17/06/2019 10:30 am

Re: ทำความรู้จักกับภาษา python (16) : การสร้างฟังก์ชันโดยมี Default Value (ดีฟอลท์ เวลู่)

โพสต์ที่ยังไม่ได้อ่าน โดย jirawoot »

โค้ด: เลือกทั้งหมด

def printinfo(name, age=24):
    print('name =', name)
    print("Age = ",age)

printinfo("python")
print('--------------')
printinfo("mindphp",30)
ผลลัพธ์
Selection_015.png
Selection_015.png (8.07 KiB) Viewed 699 times

โค้ด: เลือกทั้งหมด

def printinfo(name, age=24):
    print('name =', name)
    print("Age = ",age)

printinfo("python")
print('--------------')
printinfo("mindphp",30)
ผลลัพธ์
Selection_017.png
Selection_017.png (8.36 KiB) Viewed 699 times
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 81