NEW
Font size
WorksheetsPython
Total questions: 15
Worksheet time: 8mins
Which of the following is a valid Python variable name?
my_var
2ndVar
my-var
my var
Which Python method converts a list into a string with a delimiter?
merge()
combine()
split()
join()
What is the correct way to get the last element of a list?
my_list[0]
my_list[-1]
my_list[last]
my_list[1:]
What does the startswith() method check in a string?
If the string is uppercase.
If the string contains whitespace.
If the string starts with a specified substring.
If the string is alphanumeric.
What will print("a" in "apple") output?
True
False
Error
None
How do you access the value associated with a key in a dictionary?
dict.getKey()
dict[key]
dict.value(key)
dict(key)
Which function is used to sort a list permanently in Python?
sorted()
sort()
order()
arrange()
What is the output of print(bool(0))?
None
Error
True
False
Which of the following is NOT a valid Python loop?
while
for
do-while
nested for
What is the result of the following code? print(5 in [1, 2, 3, 4, 5])
Error
False
True
None
Which Python function can be used to convert an integer to a string?
int()
str()
string()
convert()
Which method is used to count the number of occurrences of a substring in a string?
count()
find()
index()
repeat()
What does the pass keyword do in Python?
Raises an exception.
Ends the execution of a function.
Skips the next iteration of a loop.
Acts as a placeholder and does nothing.
What will the following code output? print(type(10.5))
<class 'int'>
<class 'float'>
<class 'complex'>
<class 'decimal'>
Which Python method removes an item by its index from a list?
pop()
remove()
del
clear()
