Worksheetsการเขียนโปรแกรมภาษา python ม.5 ภาคเรียนที่ 2 ปีการศึกษา 2561
Total questions: 20
Worksheet time: 25mins
Name
Class
Date
1.
______ has one function, to output to the console (screen) whatever is inside the parentheses
a)
import
b)
input
c)
print
d)
int
2.
Which Python statement will check to see if a is greater than b?
a)
if a > b:
b)
if (a > b)
c)
if a is greater than b
d)
if a >= b:
3.
Which statement will check to see if a is equal to b?
a)
if a == b
b)
if a = b:
c)
if a != b:
d)
if a == b:
4.
Which has integer data type?
a)
Phone number
b)
Zip code
c)
HN
d)
Number of students in the class
5.
Python data type that represents text.
a)
str
b)
int
c)
bool
d)
float
6.
Python data type that allows you to work with whole numbers.
a)
str
b)
int
c)
float
d)
bool
7.
Allows your to utilize code in more than one place in a program and is defined by the keyword def
a)
argument
b)
function
c)
str
d)
bool
8.
What will the output be from the following code?
print(3+4)
print(3+4)
a)
3+4
b)
7
c)
SyntaxError
d)
print(3+4)
9.
What will the output be from the following code?
print("3+4")
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
10.
What will the output be from the following code?
print(3*4)
print(3*4)
a)
34
b)
7
c)
12
d)
3*4
11.
What will the output be from the following code?
print(3*4+5)
print(3*4+5)
a)
27
b)
17
c)
12
d)
SyntaxError
12.
What will the output be from the following code?
print("3*4+5")
print("3*4+5")
a)
SyntaxErrror
b)
17
c)
3*4+5
d)
12
13.
Converts a number to a string
a)
str()
b)
int()
c)
parseInt()
d)
convert
14.
A loop repeated if the condition is true / false
a)
While loop
b)
For loop
c)
Repeat loop
d)
If...else
15.
What does the following code do? myAge = int (myAge)
a)
Converts the var (variable) myAge to a string
b)
Converts the var (variable) myAge to a integer
c)
Converts the var (variable) myAge from a integer to a string
d)
Converts the var (variable) myAge to if statement
16.
Tells the interpreter that the code which follows is a function
a)
const
b)
int
c)
def
d)
while
17.
Leo wants to create a subroutine that will roll a dice. Which syntax is correct?
a)
def dice roll ():
b)
def diceroll ()
c)
def diceroll ():
d)
def diceroll []:
18.
What is the output of the following code?
a)
0,1,2,3,4,5,6,7,8,9,10
b)
1,2,3,4,5,6,7,8,9,10
c)
0,1,2,3,4,5,6,7,8,9
d)
1,2,3,4,5,6,7,8,9
19.
Which code can I use to print the 12 times table and get the output above?
a)
for x in range(1,12): print("12 x", x, "=", 12 * x)
b)
for x in range(0,10): print("12 x", x, "=", 12 * x)
c)
for x in range(1,10): print("12 x", x, "=", 12 * x)
d)
for x in range(1,11): print("12 x", x, "=", 12 * x)
20.
What will the following lines of code print?
a)
A
b)
B
C
C
c)
A
C
C
d)
Nothing, it will return an error.
100 %
