NEW
Font size
WorksheetsALTSCHOOL QUIZ 13/9/25
Total questions: 25
Worksheet time: 13mins
What is the correct syntax for an if-elif-else block?
if - elif - else
when - otherwise
do - if - end
switch - case - end
Which method is used to remove the last item in a list?
remove()
pop()
delete()
clear()
What will be the output of my_list = [1, 2, 3]; print(my_list[1])?
1
2
3
Error
Which method is used to retrieve all keys in a dictionary?
get()
items()
keys()
values()
What is the correct way to create a dictionary in Python?
my_dict = []
my_dict = ()
my_dict = {}
my_dict = <>
Which of the following defines a function with two parameters?
def myFunc[]:
def myFunc(x, y):
myFunc def(x y):
D. def myFunc:
What does a function return if there is no return statement?
0
False
None
Null
What keyword is used to define a function in Python?
function
def
define
fun
What is the output of for i in range(3): print(i)?
1 2 3
0 1 2
0 1 2 3
Error
Which method removes an element without error if it’s not present?
remove()
B. discard()
C. pop()
D. delete()
What happens if you try to add a duplicate to a set?
It adds the item again
It creates an error
The set stays unchanged
It creates a list
What is the output of type (set())?
dict
list
tuple
set
How do you remove all elements from a set?
clear()
del()
removeAll()
empty()
What does set1 & set2 return?
Union
Difference
Intersection
Symmetric Difference
Which operator is used for union of two sets?
&
|
^
+
What will len (set([1, 2, 2, 3])) return?
4
2
3
Error
Which method adds an element to a set?
append()
insert()
add()
extend()
What makes a set different from a list?
Sets are ordered
Sets allow duplicates
Sets are immutable
Sets don’t allow duplicates
Ho do you create a set in python
set = []
set = {}
set = set([])
set = {1, 2, 3}
What will the expression len([1, 2, 3, 4]) return?
Error
5
4
3
What does the method pop() do when called on a list?
Clears the list
Returns the list
Removes the last item
Removes the first item
Which of the following is a valid way to create a tuple in Python?
my_tuple = < >
my_tuple = ()
my_tuple = []
my_tuple = {}
What is the output of print(type({1, 2, 3}))?
set
list
dict
tuple
How do you check if an item exists in a set?
check(item) in set
item.exists(set)
set.contains(item)
item in set
What will be the output of my_set = {1, 2, 3}; my_set.add(2); print(my_set)?
{1, 2, 2, 3}
Error
{1, 2, 3}
{1, 3}
