WorksheetsPython - Grade 12
Total questions: 20
Worksheet time: 26mins
What is the correct syntax to create a list in Python?
mylist = list()
mylist = []
mylist = {}
Both A and B
What is the output of the following code?
0 1 2 3
1 2 3
0 1 2
3 2 1
Which of the following data types is mutable (can be changed)
int
float
list
str
What is the output of:
8
3
1
Error
What will this code print?
3
1
0
2
What is the type of the value returned by input()?
int
float
str
Depends on the input
Which of these statements will add an item to a list named fruits?
fruits.append("apple")
fruits.add("apple")
fruits.insert("apple")
add(fruits, "apple")
Which keyword is used to test a condition in Python?
test
loop
if
for
What will this code output?
2 3 4 5
2 3 4
3 4 5
1 2 3 4
What is the result of:
float
int
str
list
Which of these are valid Python data types?
int
list
num
bool
Which of these are valid ways to print something to the screen?
print("Hello")
echo("Hello")
print(5 + 2)
display("Hello")
Which of the following are examples of loops?
for i in range(5):
if x == 10:
loop x times:
for loop range(5)
Which statements can be used to find the minimum in a list named scores?
min(scores)
print(min(scores))
lowest(scores)
findMin(scores)
Write a Python statement to get input from the user and store it in a variable called name.
Write a for loop that prints the numbers 1 to 5.
Write a Python statement to create an empty list called grades.
If you have a list nums = [2, 7, 1, 8], write a line of code to display the smallest number.
What is the data type of the value "123" (with quotes)?
I am a sequence, yet I’m not a string.
I can hold numbers, words, or almost anything.
You can loop through me or find my length with ease.
Change one of my elements, and I’ll do it with peace.
What am I?
