0% found this document useful (0 votes)
10 views28 pages

Game

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
0% found this document useful (0 votes)
10 views28 pages

Game

Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 28

Facebook

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:

1.Creates a list named fruits containing the following elements:


'apple', 'banana', 'cherry’.
2.Adds 'orange' to the end of the list.
3.Updates the second element of the list to 'blueberry'.
4.Removes the first element of the list.
5.Prints the final list.
Multiple-Choice Questions (MCQ)
A. List
A. append()
D. Tuples are immutable.
B. By key
B. Intersection

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}

4. {'name': 'John', 'country': 'USA’}

5. [20, 30, 40]

6. Error
Code for the Problem

fruits = ['apple', 'banana', 'cherry']

fruits.append('orange')

fruits[1] = 'blueberry'

fruits.pop(0)

print(fruits)

You might also like