Game
Game
Rainbow
Armchair
1. Which Python collection is
mutable and allows duplicate
elements?
A. List
B. Tuple
C. Set
D. Dictionary
2. What method is used to add
a single element to a Python
list?
A. append()
B. extend()
C. insert()
D. add()
3. Which of the following
statements about Python tuples is
true?
A. Tuples are unordered.
B. Tuples are mutable.
C. Tuples do not allow duplicate
elements.
D. Tuples are immutable.
4. How are elements accessed
in a Python dictionary?
A. By index
B. By key
C. By slicing
D. By appending
5. What operation is used to
find common elements
between two sets in Python?
A. Union
B. Intersection
C. Difference
D. Symmetric Difference
Identify the Python collection
that stores data in key-value
pairs.
What Python collection is
unordered and does not
allow duplicate elements?
Name the method used to
remove the last element
from a Python list.
What is the term for a Python
collection that cannot be
changed after creation?
What Python function is used
to convert a list into a tuple?
WHAT IS THE OUTPUT?
my_list = [1, 2, 3]
my_list.append(4)
my_list.extend([5, 6])
my_list.insert(2, 10)
print(my_list)
my_tuple = ('apple', 'banana',
'cherry', 'date')
print(my_tuple[-2])
set1 = {1, 2, 3}
set2 = {3, 4, 5}
result = set1 | set2
print(result)
my_dict = {'name': 'John', 'age': 30, 'country': 'USA'}
my_dict.pop('age')
print(my_dict)
my_list = [10, 20, 30, 40, 50]
list = my_list[1:4]
print(list)
my_tuple = (1, 2, 3, 4)
my_tuple[2] = 10
print(my_tuple)
Write a Python program that:
Identification Questions
Dictionary
Set
pop()
Immutable
tuple()
Ouput Anwer:
1. [1, 2, 10, 3, 4, 5, 6]
2. 'cherry’
3. {1, 2, 3, 4, 5}
6. Error
Code for the Problem
fruits.append('orange')
fruits[1] = 'blueberry'
fruits.pop(0)
print(fruits)