NEW
Font size
WorksheetsALTSCHOOL AFRICA CIRCLE 7 (23/8/25)
Total questions: 25
Worksheet time: 13mins
What is the index of the first element in a Python list?
0
1
-1
None
Which of the following creates a list in Python?
list = (1,2,3)
list = {1,2,3}
list = <1,2,3>
list = [1,2,3]
Which method adds an item to the end of a list?
insert()
extend()
add()
append()
What will len([10, 20, 30]) return?
4
2
3
Error
Which of these will remove the first occurrence of 20 from [10, 20, 30, 20]?
list.pop(20)
list.delete(20)
list.discard(20)
list.remove(20)
hat is the output of x = [[1,2],[3,4]]; print(x[1][0])?
3
4
2
1
Which of the following correctly defines a nested list?
[1,2,3,4]
[1, [2, 3], 4]
[[1,2,3,4]]
Both B and C
What will x = [[10,20],[30,40]]; print(len(x)) return?
3
2
4
Error
Which statement accesses the value 20 in y = [[10, 20], [30, 40]]?
y[0][0]
y[1][0]
y[0][1]
y[1][1]
What is the output of z = [[1,2,3],[4,5]]; print(z[1][1])?
2
3
4
5
What does Python use to define code blocks?
Semicolons
Braces {}
Parentheses ()
Indentation
What will happen if indentation is not consistent in Python?
Program runs normally
IndentationError occurs
SyntaxWarning occurs
Nothing happens
Tuples in Python are:
Mutable
Immutable
Dynamic
Error-prone
Which of the following is an indentation error?
if True: print('Hello')
if True: print('Hello')
Both A and B
None
What is the default number of spaces used in Python indentation (by convention)?
2
3
4
5
Which error occurs if you mix tabs and spaces in indentation?
SyntaxError
TypeError
RuntimeError
IndentationError
Which of these creates a tuple?
t = (1,2,3)
t = [1,2,3]
t = {1,2,3}
t = <1,2,3>
Which method is not available for tuples?
count()
index()
append()
remove()
What will t = (10,); print(type(t)) output?
<class 'int'>
<class 'tuple'>
<class 'list'>
Error
What is the output of (1,2,3) + (4,5)?
(1,2,34,5)
(1,2,3,4,5)
[1,2,3,4,5]
Error
What is the output of:
x = 10if x > 5:
print("A")
else:
print("B")
A
B
Error
None
Which of the following is valid?
if x > 10 then:
if (x > 10):
if x > 10:
Both B and C
In an if-elif-else statement, when does else block run?
Only if first condition is true
Always
Never
Only if all previous conditions are false
What will this code print?
x = 0
if x:
print("Yes")
else:
print("No")
Yes
No
Error
None
What will print(type(True)) output?
<class 'int'>
<class 'bool'>
<class 'str'>
<class 'NoneType'>
