121. What is the output of print([1, 2, 3] + [4, 5])?
- a) [1, 2, 3, 4, 5]
- b) [5, 7, 3]
- c) [[1, 2, 3], [4, 5]]
- d) Error
Test your knowledge of Python with these interactive multiple-choice questions.
121. What is the output of print([1, 2, 3] + [4, 5])?
122. Which method adds an element to the end of a list?
my_list.append(x) adds x to the end of the list.
123. What does print(bool(' ')) output?
124. Which operator checks if two variables reference the same object?
is operator checks for identity, not equality.
125. What is the output of print('Python'[1:])?
126. Which method adds elements from an iterable to a list?
my_list.extend([1,2]) adds multiple elements.
127. What is the output of print('Python'.find('Py'))?
128. Which method returns a list sorted in reverse?
sorted() with reverse=True returns a new sorted list in descending order.
129. What does print('Python'[::-1]) output?
130. Which method returns the number of occurrences of a value in a list?
my_list.count(x) counts how many times x appears.
131. What is the output of print('Python'.isalnum())?
132. Which method inserts an element at a specific position?
my_list.insert(0, 'x') inserts at index 0.
133. What is the output of print('Python'.upper())?
134. Which method removes all items from a list?
my_list.clear() empties the list.
135. What does print('Python'.split('th')) return?
136. Which function returns a list of integers from start to stop?
list(range(3)) returns [0, 1, 2].
137. What is the output of print('Python'[0:6:2])?
138. Which method returns a shallow copy of a list?
my_list.copy() creates a new list with the same elements.
139. What does print('Python' * 2) output?
140. Which method returns the last index of a value in a list?