NEW
Font size
WorksheetsWeek 3-4
Total questions: 25
Worksheet time: 9mins
What is the output of min([5, 3, 8])?
8
5
3
None
Which statement about a dictionary is correct?
Keys must be immutable
Keys can be mutable
Values must be immutable
Values cannot be duplicated
What does the "symmetric_difference()" method do in sets?
Finds the common elements between two sets
Finds the difference between two sets
Finds elements not shared by two sets
None of the above
Which method is used to combine two sets?
union()
combine()
append()
add()
What does "tuple()" do?
Converts a list into a tuple
Converts a tuple into a list
Converts a string into a list
None of the above
What does the "clear()" method do in a dictionary?
Deletes all elements in a dictionary
Deletes a specific key-value pair
Creates a new dictionary
None of the above
How do you check if a key exists in a dictionary?
key in dictionary
dictionary.has_key(key)
dictionary.contains(key)
dictionary.key_exists(key)
What method is used to write data to a file in binary format?
write_binary()
write()
wb()
writefile()
Which symbol is used to separate values in a CSV file?
Semicolon
Comma
Colon
Space
Which of the following can be converted into JSON strings?
list
tuple
dictionary
All of the above
What will "os.remove()" do?
Rename a file
Delete a file
Create a file
Move a file
Which Python function is used to convert a Python dictionary into a JSON string?
json.loads()
json.dumps()
json.dump()
json.load()
What is the default file access mode when using the "open()" function?
"r"
"w"
"a"
None
Which module in Python is used to work with JSON data?
csv
json
os
file
What is the purpose of the "csv.reader()" function?
To write data into a CSV file
To read data from a CSV file
To delete a CSV file
None of the above
What does the os.getcwd() function do?
Changes the current working directory
Returns the current working directory
Deletes the current working directory
None of the above
Which method is used to sort a list in ascending order?
sorted()
sort()
arrange()
organize()
What will the expression my_list[-1] return?
The first element of the list
The last element of the list
None
IndexError
How do you check if an element exists in a list?
list.contains(element)
element in list
list.has(element)
list.find(element)
What is the format for slicing a list?
a) list[start:end]
b) list[start:end:step]
c) Both a and b
d) None of the above
Which method removes the first occurrence of a specific item in a list?
pop()
remove()
del
discard()
Which operator can be used to find the union of two sets?
|
&
-
^
What does the len() function return when applied to a list?
The number of elements in the list
The last element of the list
The size of the list in bytes
None of the above
Which method is used to add an element to the end of a list?
append()
insert()
add()
extend()
What is the primary difference between a list and a tuple in Python?
Lists are mutable, while tuples are immutable
Tuples are mutable, while lists are immutable
Both are mutable
Both are immutable
