Font size
Worksheetsบทที่ 7 : Function
Total questions: 10
Worksheet time: 7mins
หากเปรียบเทียบฟังก์ชันกับ 'เครื่องจักร' สิ่งที่ใส่เข้าไปในเครื่องเพื่อให้เครื่องทำงานเรียกว่าอะไร?
If we compare a function to a 'machine,' what is the input that makes the machine work called?
Separated by symbols:
Parameter (Input)
ใช้ [ ....]
ประโยชน์ที่สำคัญที่สุดของการใช้ฟังก์ชันคืออะไร?
What is the most important advantage of using functions?
ลดการเขียนโค้ดซ้ำและนำกลับมาใช้ใหม่ได้
Reduce code repetition and increase reuse.
เริ่มฟังก์ชันใหม่
Restart function
ตรวจสอบฟังก์ชัน
Check function
หากต้องการสร้างฟังก์ชันชื่อ 'square' เพื่อวาดรูปสี่เหลี่ยม ข้อใดคือการตั้งชื่อที่ถูกต้องตามไวยากรณ์ Python
If you want to create a function named 'square' to draw a square, which of the following is a grammatically correct naming convention in Python?
def square
def square[]:
def square():
จากโค้ดต่อไปนี้ ส่วนใดคือ 'การเรียกใช้ฟังก์ชัน' (Function Call)?
def say_hi():
print('Hello')
say_hi()
def say_hi():
say_hi()
def my_function():
print(“Hello World”)
คำสำคัญที่ใช้กำหนดฟังก์ชัน คือ?
What are the keywords used to define a function?
(a)
ฟังก์ชัน คืออะไร?
What is function?
โครงสร้างการวนซ้ำ
Loop structure
โค้ดที่จะทำงาน เมื่อถูกเรียกใช้
Code that will execute when called.
แอพพลิเคชัน
Applications
หากฟังก์ชันเปรียบเสมือน 'สูตรอาหารในสมุด' การเรียกใช้ฟังก์ชัน (Call) เปรียบได้กับอะไร?
If a function is like a 'recipe in a book,' what does a function call represent?
การสูตรเพิ่ม
Add a recipe
การลงมือทำอาหารตามสูตรนั้น
Start cooking according to the recipe.
คิดค้นสูตรอาหารใหม่
Invent new food recipes
หากต้องการสร้างฟังก์ชันชื่อ say_hello เพื่อให้แสดงคำว่า "สวัสดีจ้า" นักเรียนต้องเติมคำในช่องว่าง [1]
To create a function called say_hello that displays the words "Hello", students must fill in the blanks [1].
__1__say_hello():
print("python")
# การเรียกใช้งาน
____2____
(a)
หากต้องการสร้างฟังก์ชันชื่อ say_hello เพื่อให้แสดงคำว่า "สวัสดีจ้า" นักเรียนต้องเติมคำในช่องว่าง [2]
To create a function called say_hello that displays the words "Hello", students must fill in the blanks [2].
__1__say_hello():
print("python")
# การเรียกใช้งาน
____2____
(a)
Define: เหมือนการเขียนสูตรอาหารลงสมุด
Call: เหมือนการเริ่มลงมือทำตามสูตร
Define: Like writing a recipe in a notebook.
Call: Like starting to cook according to the recipe.
true
false
