WorksheetsPython Programming Quiz
Total questions: 50
Worksheet time: 25mins
ขั้นตอนแรกในกระบวนการแก้ปัญหาสี่ขั้นตอนในโปรแกรมพื้นฐานคืออะไร?
วิเคราะห์และกำหนดรายละเอียดของปัญหา
ดำเนินการแก้ปัญหา
วางแผนการแก้ปัญหา
ประเมินและตรวจสอบผลลัพธ์
ใครเป็นผู้พัฒนาโปรแกรมภาษา Python?
Guido van Rossum
Dennis Ritchie
James Gosling
Bjarne Stroustrup
ทำไม Python ถึงถูกพิจารณาว่าใช้งานง่ายสำหรับการเขียนโปรแกรม?
มันมีอินเทอร์เฟซที่เรียบง่ายและสนับสนุนฟีเจอร์เชิงวัตถุเช่นคลาส
มันต้องการไวยากรณ์ที่ซับซ้อน
มันสนับสนุนเฉพาะการเขียนโปรแกรมเชิงกระบวนการ
มันไม่สนับสนุนภาษาสคริปต์
สัญลักษณ์ '#' แทนอะไรในโปรแกรม Python?
จุดเริ่มต้นของฟังก์ชัน
จุดสิ้นสุดของคำสั่ง
ความคิดเห็น
การประกาศตัวแปร
บรรทัดใดในโปรแกรม Python ที่กำหนดจะแสดงผลลัพธ์บนหน้าจอ?
# โปรแกรมแรก
# คุณทำได้
print("ยินดีต้อนรับสู่ Python!")
# พิมพ์บรรทัดของข้อความ
ทำไม Python ถึงถูกพิจารณาว่าเหมาะสำหรับผู้เริ่มต้น?
มันต้องการไวยากรณ์ที่ซับซ้อน.
มันไม่เป็นที่นิยม.
มันเรียนรู้ได้ง่ายและใช้กันอย่างแพร่หลาย.
มันเหมาะสำหรับโปรแกรมเมอร์ระดับสูงเท่านั้น.
ถ้าคุณต้องการเพิ่มความคิดเห็นในโค้ด Python ของคุณ คุณควรใช้สัญลักษณ์ใด?
//
#
%
$
วัตถุประสงค์ของฟังก์ชัน print() ใน Python คือ:
เพื่อประกาศตัวแปร.
เพื่อแสดงผลลัพธ์บนหน้าจอ.
เพื่อสร้างลูป.
เพื่อเรียกใช้โมดูล.
Python ประมวลผลคำสั่งอย่างไรเมื่อรันโปรแกรม?
มันคอมไพล์คำสั่งทั้งหมดก่อนที่จะรัน.
มันแปลและรันคำสั่งในขณะทำงาน.
มันไม่สนใจคำสั่งทั้งหมด.
มันประมวลผลเฉพาะความคิดเห็นเท่านั้น.
ผลลัพธ์การทำงานของคำสั่งนี้คืออะไร print("Welcome to Python!")
Welcome to Python!
print("Welcome to Python!")
"Welcome to Python!"
No output
ในภาษา Python นามสกุลไฟล์ใดที่มักใช้เมื่อบันทึกสคริปต์ที่เขียนในโหมดสคริปต์?
.py
.txt
.exe
.doc
ข้อใดต่อไปนี้เกี่ยวกับกฎการตั้งชื่อตัวแปรใน Python ที่ถูกต้อง?
ตัวอักษรตัวแรกต้องเป็นตัวอักษรหรือตัวขีดล่าง
ตัวอักษรตัวแรกสามารถเป็นตัวเลขได้
ชื่อตัวแปรสามารถมีช่องว่างได้
คำที่สงวนไว้สามารถใช้เป็นชื่อตัวแปรได้
คำใดต่อไปนี้เป็นคำที่สงวนไว้ใน Python?
and
variable
number
main
ตัวแปรชื่อใดต่อไปนี้ที่ถูกต้องในภาษา Python?
_ThinkBig
123MyID
mylife@CMU
Pin number
ข้อใดต่อไปนี้ที่ไม่อนุญาตในชื่อของตัวแปรใน Python?
ช่องว่าง
ขีดล่าง
ตัวอักษรพิมพ์เล็ก
ตัวเลข (ไม่อยู่ที่จุดเริ่มต้น)
หากคุณต้องการตั้งชื่อให้กับตัวแปรเพื่อเก็บหมายเลขหอพัก ตัวเลือกใดต่อไปนี้ถูกต้องตามกฎการตั้งชื่อใน Python?
Dorm_number
Dorm number
123Dorm
Dorm@number
จากรายการคำสงวน คำใดต่อไปนี้สามารถใช้เป็นชื่อตัวแปรใน Python ได้?
score
for
class
return
นักเรียนต้องการตั้งชื่อให้ตัวแปรว่า "my@score" ทำไมถึงไม่อนุญาตใน Python?
มันมีอักขระพิเศษ (@).
มันเริ่มต้นด้วยตัวเลข.
มันใช้คำที่สงวนไว้.
มันยาวเกินไป.
คำใดต่อไปนี้อธิบายได้ดีที่สุดว่าทำไม "Pin number" ถึงไม่ใช่ชื่อของตัวแปรที่ถูกต้องใน Python?
ชื่อของตัวแปรไม่สามารถมีช่องว่างได้。
ชื่อของตัวแปรไม่สามารถมีตัวเลขได้。
ชื่อของตัวแปรต้องเป็นคำที่สงวนไว้。
ชื่อของตัวแปรต้องเริ่มต้นด้วยตัวอักษรตัวใหญ่。
หากคุณกำลังเขียนโปรแกรม Python และเผลอใช้ "while" เป็นชื่อของตัวแปร คุณอาจพบข้อผิดพลาดหรือปัญหาอะไร?
โปรแกรมจะไม่ทำงานเพราะ "while" เป็นคำสงวน.
โปรแกรมจะทำงานแต่จะไม่สนใจตัวแปร.
โปรแกรมจะเปลี่ยนชื่อของตัวแปรโดยอัตโนมัติ.
จะไม่มีปัญหาใดๆ เลย.
สัญลักษณ์ใดที่ใช้ในการกำหนดค่าให้กับตัวแปรใน Python?
==
:=
=
=>
ถ้าคุณเขียนคำสั่ง score = 75 ใน Python ตัวแปร score จะถือค่าแบบใด?
สตริง
จำนวนทศนิยม
จำนวนเต็ม
บูลีน
ตัวอย่างของการกำหนดค่าหลายค่าใน Python คืออะไร?
a == b == c == 1
a, b, c = 1, 2, "john"
a = b + c
a = b = c = "john"
ให้การกำหนด a, b, c = 1, 2, "john" ตัวแปร c จะมีค่าเท่าไหร่?
1
2
"john"
None
อธิบายผลลัพธ์ของคำสั่ง a = b = c = 1 ใน Python.
ตัวแปร a จะมีค่า 1 เท่านั้น.
ตัวแปร a, b, และ c จะมีค่า 1 ทั้งหมด.
ตัวแปร c จะมีค่า 1 ส่วนตัวแปรอื่นจะไม่มีการกำหนดค่า.
ตัวแปร a และ b จะมีค่า 1 ส่วน c จะมีค่า 0.
ถ้าคุณกำหนด gpa = 2.85 ใน Python ตัวแปร gpa จะถือค่าอะไร?
จำนวนเต็ม
สตริง
บูลีน
จำนวนทศนิยม
ทำไมจึงไม่จำเป็นต้องประกาศประเภทของตัวแปรก่อนที่จะกำหนดค่าใน Python?
Python จะกำหนดประเภทโดยอัตโนมัติเมื่อมีการกำหนดค่า.
Python ไม่สนับสนุนตัวแปร.
คุณต้องประกาศประเภทเสมอก่อนการกำหนดค่า.
Python สนับสนุนเฉพาะตัวแปรประเภทสตริง.
ประเภทใดต่อไปนี้เป็นประเภทข้อมูลที่ใช้แทนจำนวนเต็มในโปรแกรมมิ่ง?
int
float
string
boolean
ประเภทข้อมูลใดที่ถูกต้องสำหรับการแทนหมายเลขที่มีทศนิยม เช่น 15.20 หรือ -21.9?
int
float
boolean
list
ชนิดข้อมูลใดที่ใช้เก็บค่าที่สามารถเป็น True หรือ False เท่านั้น?
สตริง
จำนวนเต็ม
บูลีน
รายการ
ถ้าคุณเปรียบเทียบ 4 > 1 ในโปรแกรม คุณจะได้ค่าบูลีนอะไร?
เท็จ
จริง
int
float
Which of the following is NOT a basic data type mentioned in the material?
int
float
string
dictionary
Boolean ค่าใช้ในการเขียนโปรแกรมได้อย่างไรตามเนื้อหา?
เพื่อเก็บค่าทศนิยม
เพื่อตรวจสอบเงื่อนไขและควบคุมการไหลของโปรแกรม
เพื่อเก็บรายการของสิ่งของ
เพื่อแสดงข้อความ
วิธีใดต่อไปนี้ที่ไม่ใช่วิธีการกำหนดสตริงในภาษาการเขียนโปรแกรมส่วนใหญ่?
ใช้เครื่องหมายคำพูดเดี่ยว (' ')
ใช้เครื่องหมายคำพูดคู่ (" ")
ใช้เครื่องหมายคำพูดสามตัว (''' ''' หรือ """ """)
ใช้วงเล็บปีกกา ({ })
What is the purpose of using triple quotes (''' ''' or """ """) when defining a string?
To define a string with only numbers
To create a string that can span multiple lines
To make the string bold
To concatenate two strings
Given the following code: text2 = "This is a sentence." What type of quotes are used to define the string?
Single quotes
Double quotes
Triple quotes
No quotes
If you want to combine two strings in most programming languages, which operator would you use?
-
*
+
/
Suppose you have text1 = "Hello" and text2 = "World". Which expression will result in "HelloWorld"?
text1 * text2
text1 + text2
text1 / text2
text1 - text2
How can you create a string that contains multiple lines and sentences in Python?
By using single quotes
By using double quotes
By using triple quotes
By using parentheses
What is the index of the first character in a Python string?
1
0
-1
2
What will be the output of the following code? name = 'Hello World!' print(name[0])
H
e
!
W
What does the expression name[2:5] return if name = 'Hello World!'?
llo
Hel
Wo
llo W
If you want to print the string starting from the third character to the end, which Python code would you use?
print(name[3:])
print(name[2:])
print(name[:2])
print(name[1:])
What will be the result of print(name * 2) if name = 'Hello World!'?
Hello World!
Hello World!Hello World!
Hello World!TEST
Hello World!Hello
What is the output of print(name + "TEST ") if name = 'Hello World!'?
Hello World!TEST
Hello World!
Hello World!TEST Hello World!
TEST Hello World!
Which of the following is a correct way to define a list in Python?
myList = ('Hello', 'my', 'student')
myList = {'Hello', 'my', 'student'}
myList = ['Hello', 'my', 'student']
myList = "Hello, my, student"
What is the index of the last item in a list with 5 elements?
5
4
1
0
Which statement will print only the first element of the list exlist1 = ['abcd', 786, 2.23, 'john', 70.2]?
print(exlist1[1])
print(exlist1[0])
print(exlist1[2])
print(exlist1[-1])
What will be the output of print(exlist1[1:3]) if exlist1 = ['abcd', 786, 2.23, 'john', 70.2]?
['abcd', 786, 2.23]
[786, 2.23, 'john']
[786, 2.23]
['abcd', 'john']
ถ้า exlist2 = ['Hello', 'my', 'student'], ผลลัพธ์ของคำสั่ง print(exlist2 * 2) คืออะไร?
['Hello', 'my', 'student', 'Hello', 'my', 'student']
['Hello', 'my', 'student', 'student', 'my', 'Hello']
['Hello', 'Hello', 'my', 'my', 'student', 'student']
['Hello', 'my', 'student', 'Hello']
