- Function
- Function คือ วิธีการแบ่งงานออกเป็นส่วนๆ เช่น การคำนวณ แยกออกเป็น Function เพื่อง่ายต่อการใช่งานและง่ายต่อการตรวจหาข้อผิดพลาด
- วิธีการเขียน Function เบื้องต้นสำหรับการใช้งานใน python
Source Code | อธิบาย |
---|---|
- ตัวอย่าง Function Block
- การใช้งาน Function ที่มีการรับค่ามากกว่า 1 ตัวแปล
- Function อาจมีการใช้งาน return ค่ากลับ โดยใช้คำสั่ง return
Source Code | อธิบาย |
---|---|
Source Code | Result |
---|---|
- ตัวอย่างวิธีการเรียกใช้งาน function ใน python
Source Code | Result |
---|---|
Source Code | Result |
---|---|
- จงแก้ไข code ให้สามารถทำงานได้
- function list_benefits() ต้องการให้ return ค่า "More organized code", "More readable code", "Easier code reuse", "Allowing programmers to share and connect code together"
- function build_sentence(info) ต้องการให้รับค่ามา 1 ตัว และนำมาต่อท้ายด้วยคำว่า " is a benefit of functions!"
- ต้องการให้ Code ข้างล่างทำงานได้สมบูรณ์
Source Code | เฉลย |
---|---|
ไม่มีความคิดเห็น:
แสดงความคิดเห็น