0% found this document useful (0 votes)
37 views32 pages

CH 2 - Revision Tour 2 Practice Material For Board Exam - Updated

SuperNova-LearnPython is a YouTube channel that provides resources for learning Python and computer science concepts, including programming, data handling, and SQL. The document includes practice questions, true/false statements, assertion and reasoning exercises, and multiple-choice questions related to Python strings, lists, and dictionaries. It serves as a revision guide for students in classes 11 and 12, encouraging them to engage with the channel for additional learning materials.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views32 pages

CH 2 - Revision Tour 2 Practice Material For Board Exam - Updated

SuperNova-LearnPython is a YouTube channel that provides resources for learning Python and computer science concepts, including programming, data handling, and SQL. The document includes practice questions, true/false statements, assertion and reasoning exercises, and multiple-choice questions related to Python strings, lists, and dictionaries. It serves as a revision guide for students in classes 11 and 12, encouraging them to engage with the channel for additional learning materials.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

CHAPTER 1- REVISION TOUR - 2

SuperNova-LearnPython, a YouTube channel dedicated to helping


students to learn Python and computer science concepts.

The channel covers various topics related to computer science,


including Python programming, data file handling, computer
networking, SQL and many more.
You can find the channel here.
If you’re looking for video descriptions, notes, assignments, and
previous years’ question papers related to Python and computer
science for class 11 and 12, I recommend checking out the
SuperNova-LearnPython channel on YouTube.

Please like, Subscribe and share the Channel


Happy learning!

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 1 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
CHAPTER 2 –REVISION TOUR – II
[STRINGS, LISTS, TUPLES, DICTIONARY]

PRACTICE QUESTIONS
STATE TRUE OR FALSE
1. String is mutable data type.
2. Python considered the character enclosed in triple quotes

w
as String.

I
ra
3. String traversal can be done using „for‟ loop only.

pI
4. Strings have both positive and negative indexes.

xR
5. The find() and index() are similar functions.

_N
6. Indexing of string in python starts from 1.

om

cw
7. The Python strip() method removes any spaces or specified

.c
characters at the start and end of a string.

W
8.
se
The startswith() string method checks whether a string

fe
cb

R
starts with a particular substring.
n4

9.
6p
"The characters of string will have two-way indexing."
ho

s-
ASSERTION & REASONING
st
yt

1. A: Strings are immutable.


C
np

R: Individual elements cannot be changed in string in


l/U
ar

place.
ne
e

2. A: String is sequence datatype.


.L

R: A python sequence is an ordered collections of


w

ha

items where each item is indexed by an integer.


w

/c
w

3. A: a=‟3‟
m

b=‟2‟
co

c=a+b
e.

The value of c will be 5


ub

R: „+‟ operator adds integers but concatenates strings


ut

4. A:
o

a = "Hello"
.y
w

b = "llo"
w

c=a-b
w

print(c)
://

This will lead to output: "He"


s
tp

R: Python string does not support - operator


ht

5. A:
str1="Hello" and str1="World" then print(str1*3) will give
error.
R : * replicates the string hence correct output will be
HelloHelloHello

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 2 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
6. A: str1=”Hello” and str1=”World” then
print(„wo‟ not in str) will print false
R : not in returns true if a particular substring is not
present in the specified string.
7. A: The following command >>>"USA12#'.upper()
will return False.
R: All cased characters in the string are uppercase and
requires that there be at least one cased character

w
8. A: Function isalnum() is used to check whether characters

I
ra
in the string are alphabets or numbers.

pI
R: Function isalnum() returns false if it either contains

xR
alphabets or numbers

_N
9. A: The indexes of a string in python is both forward and

om
backward.

cw
R: Forward index is from 0 to (length-1) and backward

.c

W
se
index

fe
is from -1 to (-length)
cb

R
10. A: The title() function in python is used to convert the first
n4

6p
character in each word to Uppercase and remaining
ho

s-
characters to Lowercase in the string and returns an
st
yt

updated string.
C
np

l/U

R: Strings are immutable in python.


ar

OBJECTIVE TYPE QUESTIONS (MCQ)


ne
e

1. What is the output of 'hello'+1+2+3?


.L

(a) hello123 (b) hello6 (c) Error (d) Hello+6


w

ha
w

2. If n=”Hello” and user wants to assign n[0]=‟F‟ what will be


/c
w

the result?
m
co

(a) It will replace the first character


(b It‟s not allowed in Python to assign a value to an
e.
ub

individual character using index


(c) It will replace the entire word Hello into F
ut

(d) It will remove H and keep rest of the characters


o
.y

3. In list slicing, the start and stop can be given beyond


w

limits. If it is then:
w

(a) Raise exception IndexError


w
://

(b) Raise exception ValueError


s

(c) Return elements falling between specified start and stop


tp

values
ht

(d) Return the entire list

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 3 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
4. Select the correct output of the code:
Str=“Computer”
Str=Str[-4:]
print(Str*2)
a. uter b. uterretu c. uteruter d. None of these
5. Given the Python declaration s1=”Hello”. Which of the
following statements will give an error?
(a) print(s1[4]) (b) s2=s1 (c) s1=s1[4] (d) s1[4]=”Y”

w
6. Predict the output of the following code:

I
ra
RS=''

pI
S="important"

xR
for i in S:

_N
RS=i+RS

om
print(RS)

cw
7. What will the following code print?

.c

W
se
>>> print(max("zoo 145 com"))

fe
(a) 145 (b) 122 (c) z (d) zoo
cb

R
8. Ms. Hetvee is working on a string program. She wants to
n4

6p
display last four characters of a string object named s.
ho

s-
Which of the following is statement is true?
st
yt

a. s[4:] b. s[:4] c. s[-4:] d. s[:-4]


C
np

l/U

9. What will be the output of following code snippet:


ar

msg = “Hello Friends”


ne
e

msg [ : : -1]
.L

a)Hello b) Hello Friend c) 'sdneirF olleH' d) Friend


w

ha
w

10. Suppose str1= „welcome‟. All the following expression


/c
w

produce the same result except one.Which one?


m
co

(a) str[ : : -6] (b) str[ : : -1][ : : -6] (c) str[ : :6] (d) str[0] + str[-
1]
e.
ub

11. Consider the string state = "Jharkhand". Identify the


appropriate statement that will display the lastfive
ut

characters of the string state?


o
.y

(a) state [-5:] (b) state [4:] (c) state [:4] (d) state [:-4]
w

12. Which of the following statement(s) would give an error


w

during execution?
w
://

S=["CBSE"] # Statement 1
s

S+="Delhi" # Statement 2
tp

S[0]= '@' # Statement 3


ht

S=S+"Thank you" # Statement 4


(a) Statement 1 (b) Statement 2
(c) Statement 3 (d) Statement 4

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 4 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
13. Select the correct output of the following string operations
mystring = "native"
stringList = ["abc","native","xyz"]
print(stringList[1] == mystring)
print(stringList[1] is mystring)
a) True b) False c) False d) Ture
False True Flase Ture
14. Select the correct output of the code :

w
n = "Post on Twitter is trending"

I
ra
q = n.split('t')

pI
print( q[0]+q[2]+q[3]+q[4][1:] )

xR
(a)Pos on witter is rending (b)Pos on Twitter is ending
(c) Poser witter is ending (d) Poser is ending

_N
om
15. What will be the result of the following command:-

cw
>>>"i love python".capitalize()

.c

W
se
(a) 'I Love Python' (b) 'I love python'

fe
(c) 'I LOVE PYTHON' (d) None of the above
cb

R
16. The number of element return from the partition function
n4

6p
is: >>>"I love to study Java".partition("study")
ho

s-
(a) 1 (b) 3 (c) 4 (d) 5
st
yt

17. Predict the output of the following:


C
np

l/U

S='INDIAN'
ar

L=S.partition('N')
ne
e

G=L[0] + '-' + L[1] + '-' + L[2]


.L

print(G)
w

ha
w

(a) I-N-DIA-N (b) I-DIA- (c) I-DIAN (d) I-N-DIAN


/c
w

18. What will be the output of the following command:


m

>>>string= "A quick fox jump over a lazy fox"


co

>>>string.find("fox",9,34)
e.

(a) 28 (b) 29 (c) 8 (d) 7


ub

19. Select the correct option for output


ut

X="abcdef"
o
.y

i='a'
w

while i in X:
w

print(i, end=" ")


w
://

(a) Error (b) a (c) infinite loop (d) No output


s

20. What is the output of the following code?


tp

S1="Computer2023"
ht

S2="2023"
print(S1.isdigit(), S2.isdigit())
a)False True b) False False
c) True False d) True True

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 5 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
21. What will be the output of the following statement given:
txt="cbse. sample paper 2022"
print(txt.capitalize())
a) CBSE. sample paper 2022 b) CBSE. SAMPLE SAPER
2022
c) cbse. sample paper 2022 d) Cbse. Sample Paper 2022
22. Select the correct output of the code:
a = "Year 2022 at all the best"

w
a = a.split('a')

I
ra
b = a[0] + "-" + a[1] + "-" + a[3]

pI
print (b)

xR
a) Year – 0- at All the best b) Ye-r 2022 -ll the best
c) Year – 022- at All the best d) Year – 0- at all the best

_N
om
23. Select the correct output of the code:

cw
mystr = „Python programming is fun!‟

.c

W
se
mystr = mystr.partition('pro')

fe
mystr='$'.join(mystr)
cb

R
(a) Python $programming is fun!
n4

(b) Python $pro$gramming is fun! 6p


ho

s-
(c) Python$ pro$ gramming is fun!$
st
yt

(d) P$ython $p$ro$gramming is $fun!


C
np

24. Identify the output of the following Python statement:


l/U
ar

s="Good Morning"
ne
e

print(s.capitalize( ),s.title( ), end="!")


.L

(a) GOOD MORNING!Good Morning


w

ha
w

(b) Good Morning! Good Morning


/c
w

(c) Good morning! Good Morning!


m

(d) Good morning Good Morning!


co

25. What is the output of the following code?


e.

Str1="Hello World"
ub

Str1.replace('o','*')
ut

Str1.replace('o','*')
o
.y

(a) Hello World (b) Hell* W*rld


w

(c) Hello W*rld (d) Error


w

26. State whether the statement is True or False?


w
://

No matter the underlying data type, if values are equal


s

returns true.
tp

27. Predict the output of the following:


ht

S="Hello World!"
print(S.find("Hello"))
(a) 0 (b) 3 (c) [2,3,7] (d) (2,3,7)
28. Which of the following is not a valid Python String
operation?
(a) 'Welcome'+'10' (b)'Welcome'*10
(c) 'Welcome'*10.0 (d) '10'+'Welcome'
By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 6 of 32
YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
29. Which of the following statement(s) would give an error
after executing the following code?
EM = "Blue Tick will cost $8" # Statement 1
print( EM) # Statement 2
ME = "Nothing costs more than Truth" # Statement 3
EM *= 2 # Statement 4
EM [-1: -3 : -1] += ME[ : 7] # Statement 5
(a) Statement 3 (b) Statement 4

w
(c) Statement 5 (d) Statement 4 and 5

I
ra
30. Select the correct output of the following code :

pI
s="I#N#F#O#R#M#A#T#I#C#S"

xR
L=list(s.split("#"))
print(L)

_N
om
(a) [I#N#F#O#R#M#A#T#I#C#S]

cw
(b) [„I‟, „N‟, „F‟, „O‟, „R‟, „M‟, „A‟, „T‟, „I‟, „C‟, „S‟]

.c

W
(c) ['I N F O R M A T I C S']
se

fe
(d) ['INFORMATICS']
cb

R
31. STRING="WELCOME" #Line1
n4

NOTE= " " #Line2 6p


ho

s-
for S in range[0,8] #Line3
st
yt

print(STRING[S]) #Line4
C
np

print(S STRING) #Line5


l/U
ar

Which statement is wrong in above code:


ne
e

a) Line3 and Line4 b) Line4 and Line5


.L

c) Line2 and Line3 d) Line3 and Line5


w

ha
w

32. Consider the following code that inputs a string and


/c
w

removes all special characters from it after converting it to


m

lowercase.
co

s = input("Enter a string")
e.

s = s.lower()
ub

for c in ',.;:-?!()\'"':
ut

_________________
o
.y

print(s)
w

For eg: if the input is 'I AM , WHAT I AM", it should print


w

i am what i am
w

Choose the correct option to complete the code .


://
s

a. s = s.replace(c, ' ') b. s = s.replace(c, '\0')


tp

c. s = s.replace(c, None) d. s = s.remove(c)


ht

33. Which of the following statement(s) would give an error


after executing the following code?
str= "Python Programming" #S1
x= '2' #S2
print(str*2) #S3
print(str*x) #S4
(a) S1 (b) S2 (c) S3 (d) S4

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 7 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
2 –MARKS / 3 - MARKS
1. If S="python language" is a Python string, which method
will display the following output 'P' in uppercase and
remaining in lower case?
2. Rewrite the following code :
for Name in [Aakash, Sathya, Tarushi]
IF Name[0]= 'S':
print(Name)

w
3. Consider the given Python string declaration:

I
ra
>>> mystring = 'Programming is Fun'

pI
>>> printmystring[-50:10:2].swapcase())

xR
4. Rewrite the following:

_N
STRING=""WELCOME

om
NOTE = " "

cw
for S in range(0,8):

.c

W
se
if STRING[S]= ‟E‟:

fe
print(STRING(S))
cb

R
Else:
n4

print "NO" 6p
ho

s-
5. Given is a Python string declaration:
st
yt

>>>Wish = "## Wishing All Happy Diwali @#$"


C
np

l/U

Write the output of >>>Wish[ -6 : : -6 ]


ar

6. Predict the output of the following:


ne
e

Name = "cBsE@2051"
.L

R=" "
w

ha
w

for x in range (len(Name)):


/c
w

if Name[x].isupper ( ):
m
co

R = R + Name[x].lower()
elif Name[x].islower():
e.

R = R + Name[x].upper()
ub

elif Name[x].isdigit():
ut

R = R + Name[x-1]
o
.y

else:
w

R = R + "#"
w

print(R)
w
://

7. Predict the output of the following:


s

>>> 'he likes tea very much'.rstrip('crunch')


tp

>>> 'There is a mango and an apple on the table'.rstrip('ea')


ht

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 8 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
7. Find the output
Msg1="WeLcOME"
Msg2="GUeSTs"
Msg3=""
for I in range(0,len(Msg2)+1):
if Msg1[I]>="A" and Msg1[I]<="M":
Msg3=Msg3+Msg1[I]
elif Msg1[I]>="N" and Msg1[I]<="Z":

w
Msg3=Msg3+Msg2[I]

I
ra
else:

pI
Msg3=Msg3+"*"

xR
print(Msg3)
8. Predict the output of the following:

_N
om
s="3 & Four"

cw
n = len(s)

.c

W
m=""
se

fe
for i in range(0, n):
cb

R
if (s[i] >= 'A' and s[i] <= 'Z'):
n4

m = m +s[i].upper() 6p
ho

s-
elif (s[i] >= 'a' and s[i] <= 'z'):
st
yt

m = m +s[i-1]
C
np

if (s[i].isdigit()):
l/U
ar

m = m + s[i].lower()
ne
e

else:
.L

m = m +'-'
w

ha

print(m)
w

/c
w

9. Name="PythoN3.1"
m

R=" "
co

for x in range(len(Name)):
e.

if Name[x].isupper():
ub

R=R+Name[x].lower()
ut

elif Name[x].islower():
o
.y

R=R+Name[x].upper()
w

elif Name[x].isdigit():
w

R=R+Name[x-1]
w

else:
://

R=R+"#"
s
tp

print(R)
ht

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 9 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
10. Find output generated by the following code:
string="aabbcc"
count=3
while True:
if string[0]=='a':
string=string[2:]
elif string[-1]=='b':
string=string[:2]

w
else:

I
ra
count+=1

pI
break

xR
print(string)
print(count)

_N
om
11. Write the output of the code snippet.

cw
txt = "Time, will it come back?"

.c

W
x = txt.find(",")
se

fe
y = txt.find("?")
cb

R
print(txt[x+2:y])
n4

12. Predict the output of the following: 6p


ho

s-
S='Python Programming'
st
yt

L=S.split()
C
np

S=','.join(L)
l/U
ar

print(S)
ne
e

13. Predict the output of the following:


.L

S="Good Morning Madam"


w

ha
w

L=S.split()
/c
w

for W in L:
m

if W.lower()==W[::-1].lower()
co

print(W)
e.
ub

*********************************************************
o ut
.y
w
w
w
://
s
tp
ht

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 10 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
TOPIC - LIST
STATE TRUE OR FALSE
1. List immutable data type.
2. List hold key and values.
3. Lists once created cannot be changed.
4. The pop() and remove() are similar functions.
5. The append() can add an element in the middle of the list.
6. Del statement deletes sub list from a list.

w
7. Sort() and sorted() both are similar function.

I
ra
8. l1=[5,7,9,4,12] 5 not in l1

pI
9. List can be extend

xR
10. Mutable means only we can insert elements

_N
11. Index of last element in list is n-1, where n is total number

om

cw
of elements.

.c
12. We can concatenate only two list at one time.

W
13.
se
L.pop() method will return deleted element immediately

fe
cb

R
14. L.insert() method insert a new element at the beginning of
n4

the list only.


6p
ho

s-
15. If index is not found in insert() I.e. L.insert(102,89) then it
st

will add 89 at the end of the list.


yt

C
np

16. L.reverse() will accept the parameters to reverse the


l/U

elements of the list.


ar

ne

17. L.sort(reverse=1) will reverse the list in descending order


e
.L

18. L.pop() used to delete the element based on the element of


w

ha

the list.
w

/c

19. L.clear() used to clear the elements of the list but memory
w

will exists after clear.


co

20. L.append() append more than one element at the end of the
e.

list.
ub

21. L=[10,20,30]
ut

L.extend([90,100])
o

print(L)
.y
w

output of the above code is:


w

[10,20,30,[90,100]]
w

22. After sorting using L.sort() method, the index number of


://

the list element will change.


s
tp

23. L.remove() used to delete the element of the list based on


ht

its value, if the specified value is not there it will return


Error.

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 11 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
ASSERTION & REASONING
1. A: list is mutable data Type
R: We can insert and delete as many elements from list
2. A: Elements can be added or removed from a list
R: List is an immutable datatype.
3. A: List can be changed after creation
R: List is mutable datatype.
4. A: Following code will result into output : True

w
a=[10,20]

I
ra
b=a[:]

pI
print( a is b)

xR
R: "is" is used for checking whether or not both the

_N
operands is using same memory location

om
5. A: list() is used to convert string in to list element

cw
R: string will be passed into list() it will be converted into

.c

W
se
list elements

fe
cb
6. A: reverse() is used to reverse the list elements.

R
Reason: it can reverse immutable data type
n4

elements also 6p
ho

s-
7. A: pop() can delete elements from the last index of list
st
yt

R: this function can remove elements from the last index


C
np

l/U

only.
ar

8. A: len() displays the list length


ne
e

R: it is applicable for both mutable and immutable data


.L

n
w

ha

type.
w

9. A: Usha wants to sort the list having name of students of


/c
w

her class in descending order using sorted() function


co

R: sorted() function will sort the list in ascending order


e.

10. A: Raju is working on a list of numbers. He wants to print


ub

the list values using traversing method. He insists that


list can be traversed in forward direction and backward
o ut

direction i.e. from beginning to last and last to


.y

beginning.
w

R: List can be traversed from first element to last element


w
w

only.
://

11. A: Anu wants to delete the elements from the list using
s

pop() function.
tp

R: Her friend Pari suggested her to use del () function to


ht

delete more than one elements from the list.


12. A: Students in the Lab practical were asked to store
the elements in a List data type in which we can perform
all the operations like addition , deletion , deletion ,
traversal.
R: List is mutable data type

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 12 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
OBJECTIVE TYPE QUESTIONS(MCQ)
1. Which point can be considered as difference between string
and list?
(a) Length (b) Indexing and Slicing
(c) Mutability (d) Accessing individual elements
2. What is the output when we execute list(“hello”)?
(a) [„h‟, „e‟, „l‟, „l‟, „o‟] (b) [„hello‟] (c) [„llo‟] (d) [„olleh‟].
3. Given a List L=[7,18,9,6,1], what will be the output of

w
L[-2::-1]?

I
ra
(a) [6, 9, 18, 7] (b) [6,1] (c) [6,9,18] (d) [6]

pI
4. If a List L=['Hello','World!'] Identify the correct output of the

xR
following Python command: >>> print(*L)

_N
(a) Hello World! (b) Hello,World!

om
(c)'Hello','World!' (d) 'Hello','World!'

cw
5. Consider the list aList=[ "SIPO", [1,3,5,7]]. What would the

.c

W
se
following code print?

fe
cb
(a) S, 3 (b) S, 1 (c) I, 3 (d) I, 1

R
6. Suppose list1 is [1, 3, 2], What is list1 * 2 ?
n4

a) [2, 6, 4] 6p
(b) [1, 3, 2, 1, 3]
ho

s-
(c) [1, 3, 2, 1, 3, 2] (d) [1, 3, 2, 3, 2, 1]
st
yt

7. Suppose list1 = [0.5 * x for x in range(0,4)], list1 is


C
np

l/U

a) [0, 1, 2, 3] b) [0, 1, 2, 3, 4]
ar

c) [0.0, 0.5, 1.0, 1.5] d) [0.0, 0.5, 1.0, 1.5, 2.0]


ne
e

8. >>> L1=[6,4,2,9,7]
.L

n
w

ha

>>> print(L1[3:]= "100"


w

(a) [6,4,2,9,7,100] (b) [6,4,2,100]


/c
w

(c) [6,4,2,1,0,0] (d) [6,4,2, „1‟,‟0‟,‟0‟]


co

9. Which statement is not correct


e.

a)The statement x = x + 10 is a valid statement


ub

b)List slice is a list itself.


c)Lists are immutable while strings are mutable.
ut

d)Lists and strings in pythons support two way indexing


o
.y

10. Which one is the correct output for the following code?
w

a=[1,2,3,4]
w
w

b=[sum(a[0:x+1])
://

for x in range(0,len(a)):
s

print (b)
tp

(a) 10 (b) [1,3,5,7] (c) 4 (d) [1,3,6,10]


ht

11. What will be the output for the following python code:
L=[10,20,30,40,50]
L=L+5
print(L)
(a) [10,20,30,40,50,5] (b) [15,25,35,45,55]
(c) [5,10,20,30,40,50] (d) Error

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 13 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
12. Select the correct output of the code:
L1, L2 = [10, 23, 36, 45, 78], [ ]
for i in range :
L2.insert(i, L1.pop( ) )
print( L1, L2, sep=‟@‟)
(a) [78, 45, 36, 23, 10] @ [ ]
(b) [10, 23, 36, 45, 78] @ [78, 45, 36, 23, 10]
(c) [10, 23, 36, 45, 78] @ [10, 23, 36, 45, 78]

w
(d) [ ] @ [78, 45, 36, 23, 10]

I
ra
13. The append() method adds an element at

pI
(a) First (b) Last (c) Specified index (d) At any

xR
location

_N
14. The return type of x in the below code is

om
txt = "I could eat bananas all day"

cw
x = txt.partition("bananas")

.c

W
se
(a) string (b) List (c) Tuple (d) Dictionary

fe
15. S1: Operator + concatenates one list to the end of another
cb

R
list.
n4

6p
S2: Operator * is to multiply the elements inside the list.
ho

s-
Which option is correct?
st
yt

(a) S1 is correct, S2 is incorrect


C
np

(b) S1 is incorrect, S2 is incorrect


l/U
ar

(c) S1 is incorrect, S2 is incorrect


ne
e

(d) S1 is incorrect, S2 is correct


.L

16. Which of the following statement is true for extend() list


w

ha
w

method?
/c
w

(a) Adds element at last


m

(b) Adds multiple elements at last


co

(c) Adds element at specified index


e.

(d) Adds elements at random index


ub

17. What is the output of the following code?


ut

a=[1,2,3,4,5]
o

(a) 5 5 1 2 3 (b) 5 1 2 3 4
.y

for i in range(1,5):
w

a[i-1]=a[i]
w

for i in range(0,5): (c) 2 3 4 5 1 (d) 2 3 4 5 5


w
://

print(a[i],end=" ")
s
tp

18. What is the output of the functions shown below?


ht

min(max(False,-3,-4),2,7)
(a) -3 (b) -4 (c) True (d) False

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 14 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
19. If we have 2 Python Lists as follows:
L1=[10,20,30]
L2=[40,50,60]
If we want to generate a list L3 as:
then best Python command out of the following is:
(a) L3=L1+L2 (b) L3=L1.append(L2)
(c) L3=L1.update(L2) (d) L3=L1.extend(L2)
20. Identify the correct output of the following Python code:

w
L=[3,3,2,2,1,1]

I
ra
L.append(L.pop(L.pop()))

pI
print(L)

xR
(a) [3,2,2,1,3] (b)[3,3,2,2,3] (c)[1,3,2,2,1] (d)[1,1,2,2,3,3]

_N
21. Predict the output of the following:

om
L1=[1,4,3,2]

cw
L2=L1

.c

W
se
L1.sort()

fe
print(L2)
cb

R
(a) [1,4,3,2] (b)[1,2,3,4] (c) 1 4 3 2 (d) 1 2 3 4
n4

22. If PL is Python list as follows: 6p


ho

s-
PL=['Basic','C','C++']
st
yt

Then what will be the status of the list PL after


C
np

PL.sort(reverse=True) ?
l/U
ar

(a) ['Basic','C','C++'] (b) ['C++','C','Basic']


ne
e

(c) ['C','C++','Basic'] (d) PL=['Basic','C++','C']


.L

23. Given list1 = [34,66,12,89,28,99]


w

ha
w

Statement 1: list1.reverse()
/c
w

Statement 2: list1[::-1]
m

Which statement modifies the contents of original list1.


co

(a) Statement 1 (b) Statement 2


e.

(c) Both Statement 1 and 2. (d) None of the mentioned


ub

24. which command we use can use To remove string "hello"


ut

from list1, Given, list1=["hello"]


o
.y

(a) list1.remove("hello") (b) list1.pop(list1.index('hello'))


w

(c) Both A and B (d) None of these


w

25. How would you create a loop to iterate over the contents of
w
://

the list given as Days = [31, 28, 31, 30, 31, 30, 31, 31,30]
s

and print out each element?


tp

(a) for days in range(Days):


ht

print(days)
(b) for days in Days:
print(days)
(c) for days in range(len(Days)):
print(days)
(d) for days in Days:
print(monthDays)

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 15 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
25. Predict the output of the following:
S=[['A','B'],['C','D'],['E','F']]
print(S[1][1])
(a)'A' (b) 'B' (c) 'C' (d) 'D'
26. Predict the output of the following:
L1=[1,2,3]
L2=[4,5]
L3=[6,7]

w
L1.extend(L2)

I
ra
L1.append(L3)

pI
print(L1)

xR
(a) [1,2,3,4,5,6,7] (b)[1,2,3,[4,5],6,7]
(c) [1,2,3,4,5,[6,7]] (d)[1,2,3,[4,5],[6,7]]

_N
om
27. State True or False "There is no conceptual limit to the size

cw
of a list."

.c

W
se
28. The statement del l[1:3] do which of the following task?

fe
a. deletes elements 2 to 4 elements from the list
cb

R
b. deletes 2nd and 3rd element from the list
n4

6p
c. deletes 1st and 3rd element from the list
ho

s-
d. deletes 1st, 2nd and 3rd element from the list
st
yt

29. Which of the following will give output as: [23, 2, 9, 75]?
C
np

l/U

If list1=[6,23,3,2,0,9,8,75]
ar

(a) print(list1[1:7:2]) (b) print(list1[0:7:2])


ne
e

(c) print(list1[1:8:2]) (c) print(list1[0:8:2])


.L

30. Find the output


w

ha
w

values = [[3, 4, 5, 1 ], [33, 6, 1, 2]]


/c
w

for row in values:


m

row.sort()
co

for element in row:


e.

print(element, end = " ")


ub

print()
ut

(a). The program prints on row 3 4 5 1 33 6 1 2


o
.y

(b). The program prints two rows 3 4 5 1


w

followed by 33 6 1 2
w

(c). The program prints two rows 3 4 5 1


w
://

followed by 33 6 1 2
s

(d). The program prints two rows 1 3 4 5


tp

followed by 1 2 6 33
ht

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 16 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
2 MARKS / 3 MARKS
1. (a) >>>L=[1,"Computer",2,"Science",10,"PRE",30,"BOARD"]
>>>print(L[3:])
(b) Identify the output of the following Python statements.
>>>x = [[10.0, 11.0, 12.0],[13.0, 14.0, 15.0]]
>>>y = x[1][2]
>>>print(y)
2. Write the output of following code:

w
lst1=[10,15,20,25,30]

I
ra
lst1.insert(3,4)

pI
lst1.insert(2,3)

xR
print(lis[-5])

_N
3. Write output for the following code:

om
list1=[x+2 for x in range(5)]

cw
print(list1)

.c

W
se
4. What will be the output of the following code?

fe
a=[1,2,3,4]
cb

R
s=0
n4

for a[-1] in a: 6p
ho

s-
print(a[-1])
st
yt

s+=a[-1]
C
np

l/U

print(„sum=‟,s)
ar

5. Predict the output of the following:


ne
e

(i) L=[10,20]
.L

L1=[30,40]
w

ha
w

L2=[50,60]
/c
w

L.append(L1)
m

L.extend(L2)
co

print(L)
e.

5. Predict the output of the following:


ub

(ii) M=[11, 22, 33, 44]


ut

Q=M
o
.y

M[2]+=22
w

L=len(M)
w

for i in range (L):


w
://

print("Now@", Q[L-i-1], "#", M[i])


s

6. Predict the output of the Python code given below:


tp

l=[ ]
ht

for i in range(4):
l.append(2*i+1)
print(l[::-1])

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 17 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
7. Predict the output of the following:
TXT = ["10","20","30","5"]
CNT = 3
TOTAL = 0
for C in [7,5,4,6]:
T = TXT[CNT]
TOTAL = float (T) + C
print (TOTAL)

w
CNT-=1

I
ra
8. Write the output of the following:

pI
x = [[1, 2, 3],[4, 5, 6],[7, 8, 9]]

xR
result = []
for items in x:

_N
om
for item in items:

cw
if item % 2 == 0:

.c

W
result.append(item)
se

fe
print(result)
cb

R
9. Write the output of the following python code:
n4

Numbers =[9,18,27,36] 6p
ho

s-
for num in Numbers:
st
yt

for N in range(1,num%8):
C
np

print(N,"$",end="")
l/U
ar

print()
ne
e

10. Predict the output of the following:


.L

List1 = list("Examination")
w

ha
w

List2 =List1[1:-1]
/c
w

new_list = []
m

for i in List2:
co

j=List2.index(i)
e.

if j%2==0:
ub

List1.remove(i)
ut

print(List1)
o
.y

11. Predict the output of the following:


w

fruit_list1 = ['Apple', 'Berry', 'Cherry', 'Papaya']


w

fruit_list2 = fruit_list1
w

fruit_list3 = fruit_list1[:]
://
s

fruit_list2[0] = 'Guava'
tp

fruit_list3[1] = 'Kiwi'
ht

sum = 0
for ls in (fruit_list1, fruit_list2, fruit_list3):
if ls[0] == 'Guava':
sum += 1
if ls[1] == 'Kiwi':
sum += 20
print(sum)

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 18 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
12. Predict the output of the following:
L1,L2=[10,15,20,25],[ ]
for i in range(len(L1)):
L2.insert(i,L1.pop())
print(L1,L2,sep='&')
14. Predict the output of the following:
L1=[10,20,30,20,10]
L2=[ ]

w
for i in L1:

I
ra
if i not in L2:

pI
L2.append(i)

xR
print(L1,L2,sep='$')

_N
15. Predict the output of the following:

om
num=[10,20,30,40,50,60]

cw
for x in range(0,len(num),2):

.c

W
se
num[x], num[x+1]=num[x+1], num[x]

fe
print(num)
cb

R
16. Predict the output of the following:
n4

L=[1,2,3,4,5] 6p
ho

s-
Lst=[]
st
yt

for i in range(len(L)):
C
np

if i%2==1:
l/U
ar

t=(L[i],L[i]**2)
ne
e

Lst.append(t)
.L

print(Lst)
w

ha
w

17. Predict the output of the following:


/c
w

sub=["CS", "PHY", "CHEM", "MATHS","ENG"]


m

del sub[2]
co

sub.remove("ENG")
e.

sub.pop(1)
ub

print(sub)
ut

18. Predict the output of the following:


o
.y

Predict the output:


w

list1 =['Red', 'Green', 'Blue', 'Cyan','Magenta','Yellow',]


w

print(list1[-4:0:-1])
w
://

19. Predict the output of the following:


s

L=[10,20,40,50,60,67]
tp

L[0:3]="100"
ht

print(L)

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 19 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
20. Predict the output of the following:
lst = [40, 15, 20, 25, 30]
lst.sort()
lst.insert(3, 4)
lst.append(23)
print(lst)
21. Predict the output of the following:
L=[10,2,5,-1,90,23,45]

w
L.sort(reverse=True)

I
ra
S=L.pop(2)

pI
L.insert(4,89)

xR
L.sort()
L.remove(90)

_N
om
print(L)

cw
22. Predict the output of the following:

.c

W
se
L=[10,2,5,-1,90,23,45]

fe
L.sort(reverse=True)
cb

R
G=L.append(L.pop(L.pop()))
n4

print(G) 6p
ho

s-
23. Predict the output of the following:
st
yt

L=['30','40','20','50']
C
np

count=3
l/U
ar

Sum=0
ne
e

P=[]
.L

for i in[6,4,5,8]:
w

ha
w

T=L[count]
/c
w

Sum=float(T)+i
m

P.append(Sum)
co

count-=1
e.

print(P)
ub

print(P[3:0:-1])
ut

for i in[0,1,2,3]:
o
.y

P[i]=int(P[i])+10
w

print(P)
w

24. Predict the output of the following:


w

L=['FORTRAN','C++','Java','Python']
://
s

L.insert(2,"HTML")
tp

del L[4]
ht

L.remove('Java')
L.pop()
L.insert(1,"PHP")
L.sort()
L.pop()
print(L)
*********************************************************
By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 20 of 32
YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
TOPIC - TUPLES
STATE TRUE OR FALSE
1. Tuple data structure is mutable
2. tuples allowed to have mixed lengths.
3. tuple have one element for Ex: S=(10)
4. We Can concatenate tuples.
5. The elements of the of a tuple can be deleted
6. A tuple storing other tuples is called as nested tuple

w
7. The + Operator adds one tuple to the end of another tuple

I
ra
8. A tuple can only have positive indexing.

pI
ASSERTION & REASONING

xR
1. A: Tuples are ordered

_N
R: Items in a tuple has an defined order that will not be

om

cw
changed.

.c
2. A: A tuple can be concatenated to a list, but a list cannot

W
be concatenated to a tuple.
se

fe
cb

R
R: Lists are mutable and tuples are immutable in Python
n4

3. A: Tuple is an in inbuilt data structure


6p
ho

s-
R: Tuple data structure is created by the programmers and
st

not by the creator of the python


yt

C
np

4. a=(1,2,3)
l/U

a[0]=4
ar

ne

A: The above code will result in error


e
.L

R: Tuples are immutable. So we cant change them.


w

ha

5. A: A tuple cannot be sorted inline in python and therefore


w

/c

sorted () returns a sorted list after sorting a tuple.


w

R: Tuples are non-mutable data type


co

6. >>> tuple1 = (10,20,30,40,50)


e.

>> tuple1.index(90)
ub

A: Above statements gives ValueError in python


ut

R: ValueError: tuple.index(x): x not in tuple


o

7. T1 = (10, 20, (x, y), 30)


.y
w

print(T1.index(x))
w

A: Above program code displays the index of the element „x‟


w

R: Returns the index of the first occurrence of the


://

element in the given tuple


s
tp

8. >>>tuple1 = (10,20,30,40,50,60,70,80)
ht

>>>tuple1[2:]
Output: (30, 40, 50, 60, 70, 80)
A: Output given is incorrect
R: Slicing in above case ends at last index

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 21 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
9. A:
t=(10,20,30)
t[1]=45
the above mentioned question will throws an error.
R: Tuple are used to store sequential data in a program
10. A: Forming a tuple from individual values is called packing
R: Many individual data can be packed by assigning them
to one single variable, where data is separated by

w
comma.

I
ra
OBJECTIVE TYPE QUESTIONS (MCQ)

pI
1. Which of the following statement creates a tuple?

xR
a) t=[1,2,3,4] b) t={1,2,3,4} c) t=<1,2,3,4> d)

_N
t=(1,2,3,4)

om

cw
2. Which of the following operation is supported in python

.c
with respect to tuple t?

W
se
a) t[1]=33 b) t.append(33) c) t=t+t d) t.sum()

fe
cb
3. Which of the following is not a supported operation in

R
n4

6p
Python?
(a) “xyz”+ “abc” (b) (2)+(3,) (c) 2+3 (d) [2,4]+[1,2]
ho

s-
4. Predict the output:
st
yt

T=('1')
np

l/U

print(T*3)
ar

(a) 3 (b) ('1','1','1') (c) 111 (d) ('3')


ne
e
.L

5. Identify the errors in the following code:


n
w

ha

MyTuple1=(1, 2, 3) #Statement1
w

/c

MyTuple2=(4) #Statement2
w

MyTuple1.append(4) #Statement3
co

print(MyTuple1, MyTuple2) #Statement4


e.

(a) Statement 1 (b) Statement 2


ub

(c) Statement 3 (d) Statement 2 &3


ut

6. Suppose a tuple Tup is declared as Tup = (12, 15, 63, 80)


o

which ofthe following is incorrect?


.y

(a) print(Tup[1]) (b) Tup[2] = 90


w

(c) print(min(Tup)) (d) print(len(Tup))


w
w

7. Predict the output of the following code:


://

t1=(2,3,4,5,6)
s

print(t1.index(4))
tp
ht

(a) 4 (b) 5 (c) 6 (d) 2

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 22 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
8. Given tp = (1,2,3,4,5,6). Which of the following two
statements will give the same output?
1. print(tp[:-1]) # Statement 1
2. print(tp[0:5]) # Statement 2
3. print(tp[0:4]) # Statement 3
4. print(tp[-4:]) # Statement 4
(a) Statement 1 and 2 (b) Statement 2 and 4
(c) Statement 1 and 4 (d) Statement 1 and 3

w
9. What will be the output for the following Python

I
ra
statement?

pI
T=(10,20,[30,40,50],60,70)

xR
T[2][1]=100

_N
print(T)

om
(a) (10,20,100,60,70) (b) 10,20,[30,100,50],60,70)

cw
.c
(c) (10,20,[100,40,50],60,70) (d) None of these

W
se
10. Which of the following is an unordered collection of

fe
cb
elements

R
(a) List (b) Tuple (c) Dictionary (d) String
n4

11. 6p
Consider the following statements in Python and the
ho

s-
question that follows:
st
yt

i. Tuple is an ordered list


C
np

l/U

ii. Tuple is a mutable data type


ar

From the above statements we can say that


ne
e

(a) Only (i) is correct


.L

n
w

ha

(b) Only (ii) is correct


w

(c) Both (i) and (ii) are correct


/c
w

(d) None of (i) and (ii) are correct


co

12. Which of the following is not a tuple in Python?


(a) (1,2,3) (b) (“One”,”Two”,”Three”) (c) (10,) (d) (“One”)
e.
ub

13. Suppose a tuple T is declared as T=(10,20,30) and a list


L=["mon", "tue", "wed","thu", "fri", "sat", "sun"], which of the
out

following is incorrect ?
.y

a) min(L) b) L[2] = 40 c) T[3] = “thurs” d) print(


w

min(T))
w
w

14. Suppose a Python tuple T is declared as:


://

T=('A','B','C')
s

Which of the following command is invalid?


tp

(a) T=('D') (b) T=('D',) (c) T+=('D') (d) T+=('D',)


ht

15. Predict the output:


tup1 = (2,4,[6,2],3)
tup1[2][1]=7
print(tup1)
(a)Error (b) (2,4,[6,2],3) (c)(2,4,[6,7],3) (d)(2,4,6,7,3)

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 23 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
16. Consider a tuple t=(2,4,5), which of the following will give
error?
(a) list(t)[-1]=2 (b) print(t[-1]) (c) list(t).append(6) (d) t[-1]=7
17. Suppose a tuple T1 is declared as T1 = (10, 20, 30, 40, 50)
which of the following is incorrect?
a)print(T[1]) b) T[2] = -29 c) print(max(T)) d) print(len(T))
18. What will be the output of the following Python code ?
T1= ( )

w
T2=T1 * 2

I
ra
print(len(T2))

pI
(a) 0 (b) 2 (c) 1 (d) Error

xR
19. Predict the output:

_N
Tup=(3,1,2,4)

om
sorted(Tup)

cw
.c
print(Tup)

W
se
(a) (3,1,2,4) (b) (1,2,3,4) (c) [3,1,2,4] (d) [1,2,3,4]

fe
cb
20. Predict the output of the following:

R
n4

S=([1,2],[3,4],[5,6])
S[2][1]=8 6p
ho

s-
print(T)
st
yt

(a) ([1,2],[8,4],[5,6])
np

l/U

(b) ([1,2],[3,4],[8,6])
ar

(c) ([1,2],[3,4],[5,8])
ne
e
.L

(d) Will generate an Error as a Tuple is immutable


n
w

ha
w

/c
w

m
co
e.
ub
out
.y
w
w
w
s://
tp
ht

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 24 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
2 MARKS / 3 MARKS
1. Predict the output of the following:
test_list = [5, 6, 7]
test_tup = (9, 10)
res = tuple(list(test_tup) + test_list)
print(str(res))
2. tuple1 = (5, 12, 7, 4, 9 ,6)
list1 =list(tuple1)

w
list1.insert(2,8)

I
ra
list1.pop()

pI
tuple1=tuple(list1)

xR
print(tuple1)

_N
3. Predict the output of the following code:

om
tuple1 = ( [7,6], [4,4], [5,9] , [3,4] , [5,5] , [6,2] , [8,4])

cw
.c
listy = list( tuple1)

W
se
new_list = list()

fe
cb
for elem in listy :

R
tot = 0
n4

for value in elem: 6p


ho

s-
tot += value
st
yt

if elem.count(value) == 2:
C
np

l/U

new_list.append(value)
ar

tot = 0
ne
e

else:
.L

n
w

ha

print( tuple(new_list) )
w

4. Write the output of the code given below:


/c
w

a,b,c,d = (1,2,3,4)
co

mytuple = (a,b,c,d)*2+(5**2,)
print(len(mytuple)+2)
e.
ub

5. Predict the output


ut

******************************************************
o
.y
w
w
w
://
s
tp
ht

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 25 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
TOPIC - DICTIONARY
STATE TRUE OR FALSE
1. Dictionary values are immutable
2. List can be converted in Dictionary
3. It is always not necessary to enclose dictionary in { }.
4. Dictionary keys are unique and always of string type
5. D.popitem() is used to delete the last items of the

w
dictionary.

I
ra
6. D.get() method is used to insert new key:value pair inside

pI
of the dictionary.

xR
ASSERTION & REASONING

_N
1. A: Dictionaries are mutable.

om
R: Individual elements can be changed in dictionary in

cw
.c
place.

W
se
2. A: Dictionary in Python holds data items in key-value pairs

fe
cb
R: Immutable means they cannot be changed after

R
creation.
n4

3. A: Key of dictionary can‟t be changed. 6p


ho

s-
R: Dictionary Key‟s are immutable.
st
yt

4. A: Key of dictionary must be single element.


np

l/U

R: Key of dictionary is always string type.


ar

5. A: Dictionary and set both are same because both enclosed


ne
e
.L

in { }.
n
w

ha

R: Dictionary is used to store the data in a key-value pair


w

format.
/c
w

6. A: The pop() method accepts the key as an argument and


co

remove the associated value


e.

R: pop() only work with list because it is mutable.


ub

7. A: The items of the dictionary can be deleted by using the


ut

del keyword.
o

R: del is predefined keyword in python.


.y
w
w
w
://
s
tp
ht

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 26 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
OBJECTIVE TYPE QUESTIONS (MCQ)
1. Which statement is correct for dictionary?
(a) A dictionary is a ordered set of key: value pair
(b) each of the keys within a dictionary must be unique
(c) each of the values in the dictionary must be unique
(d) values in the dictionary are immutable
2. Which of the following is the correct statement for checking
the presence of a key in the dictionary?

w
a) <key> in <dictionary_obj>

I
ra
b) <key> not in <dictionary_obj>

pI
c) <key> found in <dictionary_obj>

xR
d) a) <key> exists in <dictionary_obj>

_N
3. What will be the output for the following Python statements?

om
D= {“Amit”:90, “Reshma”:96, “Suhail”:92, “John”:95}

cw
.c
print(“John” in D, 90 in D, sep= “#”)

W
se
(a) True#False (b)True#True (c) False#True (d) False#False

fe
cb
4. Choose the most correct statement among the following –

R
n4

(a) a dictionary is a sequential set of elements


6p
(b) a dictionary is a set of key-value pairs
ho

s-
(c) a dictionary is a sequential collection of elements key-
st
yt

value pairs
np

l/U

(d) a dictionary is a non-sequential collection of elements


ar

5. What will be output of the following code:


ne
e
.L

d1={1:2,3:4,5:6}
n
w

ha

d2=d1.popitem()
w

print(d2)
/c
w

(a) {1:2} (b) {5:6} (c) (1,2) (d) (5,6)


co

6. Which of the following statements create a dictionary?


e.

a) d = { } b) d = {"john":40, "peter":45}
ub

c) d = {40: "john", 45: "peter"} d) All of the mentioned above


ut

7. What will be output of following:


o

d = {1 : "SUM", 2 : "DIFF", 3 : "PROD"}


.y

for i in d:
w

print (i)
w
w

8. Predict the output of the following:


://

D={1:"One",2:"Two",3:"Three"}
s

L=[ ]
tp
ht

for K,V in D.items():


if V[0]=="T":
L.append(K)
print(L)
(a) [1,2,3] (b) ["One","Two","Three"]
(d) [2,3] (d) ["Two","Three"]

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 27 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
9. Given the following dictionary
employee={'salary':10000,'age':22,'name':'Mahesh'}
employee.pop('age')
print(employee)
What is output?
a. {„age‟:22}
b. {'salary': 10000, 'name': 'Mahesh'}
c. {'salary':10000,'age':22,'name':'Mahesh'}

w
d. None of the above

I
ra
10. D={'A':1, 'B':2, 'C':3}

pI
Then, which of the following command will remove the

xR
entire dictionary from the memory?

_N
(a) del(D) (b) D.del() (c) D.clear() (d) D.remove()

om
11. Predict the output of the following:

cw
.c
D1={'A':5,'B':5,'C':9,'D':10}

W
se
D2={'B':5,'D':10}

fe
cb
D1.update(D2)

R
print(D1)
n4

6p
(a) {'A':5,'B':5,'C':9,'D':10} (b) {'A':5,'B':5,'C':9,'B':5,'D':10}
ho

s-
(c) {'A':5,'C':9,'D':10} (d) {'B':7,'D':10,'A':5,'C':9}
st
yt

12. Predict the output of the following:


C
np

l/U

D1={1:2,2:3,3:4}
ar

D2=D1.get(1,2)
ne
e

print(D2)
.L

n
w

ha

(a) 2 (b) 3 (c) [2,3] (d) {1:2,2:3}


w

13. Which of the following operation(s) supported in


/c
w

Dictionary?
co

(a) Comparison(only = and !=) (b) Membership


(c) Concatenation
e.

(d) Replication
ub

14. Predict the output of the following:


D1={1:10,4:56,100:45}
o ut

D2={1:10,4:56,45:100}
.y

print(D1==D2)
w

(a) True (b) False


w
w

(c) Cannot Compare the dictionaries (d) Error


://

15. Predict the output of the following:


s

D1={1:10,4:56,100:45}
tp

D2={1:10,4:56,45:100}
ht

print(D1<=D2)
(a) True (b) False
(c) Cannot Compare the dictionaries (d) Error

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 28 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
16. Write a python command to create list of keys from a
dictionary.
dict={'a':'A', 'b':'B','c':'C', 'd':'D'}
(a) dict.keys() (b) keys() (c) key.dict() (d) None of these
17. What will the following code do?
dict={“Phy”:94,”Che”:70,”Bio”:82,”Eng”:95}
dict.update({“Che”:72,”Bio”:80})

w
(a) It will create new dictionary as dict={“Che”:72,”Bio”:80}

I
and old dict will be deleted.

ra
pI
(b) It will throw an error as dictionary cannot be updated.

xR
(c) It will simply update the dictionary as
dict={“Phy”:94,”Che”:72,”Bio”:80, “Eng”:95}

_N
om
(d) It will not throw any error but it will not do any changes

cw
in dict.

.c

W
18. Consider the coding given below and fill in the blanks:
se

fe
Dict_d={„BookName‟:‟Python‟,‟Author‟:”Arundhati Roy”}
cb

R
Dict_d.pop() # Statement 1
n4

List_L=[“java”,”SQL”,”Python”] 6p
ho

s-
List_L.pop() # Statement 2
st
yt

(i) In the above snippet both statement 1 and 2 deletes the


C
np

last element from the object Dict_d and


l/U
ar

List_L________(True/False).
ne
e

(ii) Statement_______(1/2) alone deletes the last element in


.L

its object
w

ha

19. Identify the output of following code


w

/c
w

d={'a':'Delhi','b':'Mumbai','c':'Kolkata'}
m

for i in d:
co

if i in d[i]:
e.

x=len(d[i])
ub

print(x)
ut

(a) 6 (b) 0 (c) 5 (d) 7


o

20. What will be the output of the following code?


.y
w

D1={1: "One",2: "Two", 3: "C"}


w

D2={4: "Four",5: "Five"}


w

D1.update(D2)
://

print (D1)
s
tp

a) {4: "Four",5: "Five"}


ht

b) Method update() doesn‟t exist for dictionary


c) {1:"One",2:"Two", 3: "C"}
d) {1:"One",2: "Two",3: "C",4:"Four",5: "Five"}

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 29 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
21. Given the following dictionaries
Dict1={'Tuple': 'immutable', 'List': 'mutable', 'Dictionary':
'mutable', 'String': 'immutable'}
Which of the following will delete key:value pair for
key=„Dictionary‟ in the above mentioned dictionary?
(a) del Dict1['Dictinary']
(b) Dict1[„Dictionary‟].delete( )
(c) delete (Dict1.["Dictionary"])

w
(d) del(Dict1.[„Dictionary‟])

I
ra
2 MARKS / 3 -MARKS

pI
1. Write a statement in Python to declare a dictionary whose

xR
keys are Sub1, Sub2, Sub3 and values are Physics,

_N
Chemistry, Math respectively.

om
2. Debug the following code and underline the correction

cw
.c
made:

W
se
d=dict{ }

fe
cb
n=input("enter number of terms")

R
for i in range(n):
n4

a=input("enter a character") 6p
ho

s-
d[i]=a
st
yt

3. Write the output of the code given below:


np

l/U

>>>squares = {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}


ar

>>>print(squares.pop(4))
ne
e
.L

4. Write the output of the code given below :


n
w

ha

Emp = { "SMITH":45000 , "CLARK":20000 }


w

Emp["HAPPY"] = 23000
/c
w

Emp["SMITH"] = 14000
co

print( Emp.values())
e.

5. What will be the output of the following Python code?


ub

d1={"a":10,"b":2,"c":3}
str1=""
o ut

for i in d1:
.y

str1=str1+str(d1[i])+" "
w

str2=str1[ : -1]
w
w

print(str2[: : -1])
://

6. Predict the output of the Python Code given below:


s

d={"Rohan":67,"Ahasham":78,"naman":89,"pranav":79}
tp

print(d)
ht

sum=0
for i in d:
sum+=d[i]
print(sum)
print("sum of values of dictionaries",sum)

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 30 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
7. Predict the output of
d={2:'b',4:'c'}
d1={1:'a'}
d.update(d1)
d[1]='v'
print(list(d.values()))
8. Mydict={ }
Mydict[(1,2,3)]=12

w
Mydict[(4,5,6)]=20

I
ra
Mydict[(1,2)]=25

pI
total=0

xR
for i in Mydict:

_N
total=total+Mydict[i]

om
print(total)

cw
.c
print(Mydict)

W
se
9. Write the output of the code given below:

fe
cb
d1 = {"name": "Aman", "age": 26}

R
d2 = {27:'age','age':28}
n4

d1.update(d2) 6p
ho

s-
print(d1.values())
st
yt

10. Write the output of the following code given below:


C
np

l/U

Marks = {'Sidhi':65, 'Prakul':62, 'Suchitra':64, 'Prakash':50}


ar

ne

newMarks = {'Suchitra':66,'Arun':55,'Prkash':49}
e
.L

Marks.update(newMarks)
w

ha

for key,value in Marks.items():


w

/c
w

print(key,'scored',value,'marks in Pre Board',end=' ')


m

if(value<55):
co
e.

print(„and needs imporovement‟end=‟.‟)


ub

print()
ut

11. Write the output of the following Python program code:


o

my_dict = { }
.y

my_dict[(1,2,4)] = 8
w
w

my_dict[(4,2,1)] = 10
w

my_dict[(1,2)] = 12
://

sum = 0
s
tp

for k in my_dict:
ht

sum += my_dict[k]
print (sum)
print(my_dict)

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 31 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw
12. Predict the output of the following:
D={ }
T=("Raj","Anu","Nisha","Lisa")
for i in range(1,5):
D[i]=T[i-1]
print(D)
13. Predict the output of the following:
S="UVW"

w
L=[10,20,30]

I
ra
D={ }

pI
N=len(S)

xR
for i in range(N):

_N
D[L[i]]=S[i]

om
for K,V in D.items():

cw
.c
print(K,V,sep="*",end=",")

W
se
14. What will be the output, given by the following piece

fe
cb
of code:

R
D1= {"A":12, "B": 6, "C" : 50, "D" : 70}
n4

print (50 in D1,"C" in D1,sep="#") 6p


ho

s-
15. Predict the output of the following:
st
yt

P=1400
C
np

l/U

D={'KTM':45,'RoyalEnfield':75,'Jawa':33,'TVS':89,
ar

'Yamaha':111}
ne
e

for j in D:
.L

n
w

ha

if(len(j)>5):
w

P=P-D[j]
/c
w

print(j)
co

X={'Suzuki':1000,'Bajaja':21}
D.update(X)
e.
ub

print(X)
print(D)
ut

print(D.get('Jawa','KTM'))
o
.y
w
w
w

*****************************************************
://
s
tp
ht

By: Amjad Khan Website: https://www.learnpython4cbse.com/ Page 32 of 32


YouTube: https://www.youtube.com/channel/UCsts-6pRfeWcw_NxRpIraIw

You might also like