Font size
WorksheetsPython Quiz - Data type, If/Else, Coding
Total questions: 30
Worksheet time: 20mins
holds whole numbers
holds a decimal point in a number
what is the code for a STRING in python?
str
stri
string
What will the output of the following code be?
for i in ["A", "b", "3"]:
print(i)
Error
"A"
"b"
"3"
A, b, 3
A
b
3
What is the output of the code below?
x = 5
if x == 0:
print("x is 0")
elif x > 1:
print("x is greater than 1")
elif x > 3:
print("x is greater than 3")
x is 0
x is greater than 1
x is greater than 3
for a in range(3):
print(a)
1
2
3
0
1
2
1 2 3
Error
What is the value of b?
a = 0
b = a
a = 3
0
3
Which of the following commands exists?
.upper()
.casefold()
.destroy()
.TextChar
What is the output of this code?
string = "Python Test"
for i in string.split():
print (i, end=", ")
P, y, t, h, o, n, T, e, s, t,
Python, Test,
P, y, t, h, o, n, ,T, e, s, t,
What is the output of the code?
a = (33, 55)
a.append(22)
print(a)
33 55 22
33
55
22
33, 55, 22
Error
What is the output of the code?
people = ["Bob", "John", "Mark"]
print(people[1])
Bob
John
Mark
Error
What is the output of the code?
people = ["Bob", "John", "Mark"]
print(people[-1])
Bob
John
Mark
Error
What is the output of the following?
i = 1
while True:
if i%2 == 0:
break
print(i)
i += 2
1
1 2
1 2 3 4 5 6...
1 3 5 7 9 11....
What is the output of the following?
for i in range(10):
if i == 5:
break
else:
print(i)
else:
print("Here")
0 1 2 3 4 Here
0 1 2 3 4 5 Here
0 1 2 3 4
1 2 3 4 5
