Page 1 :
Chapter ‘, Practice aa, , ene el, , Objective Questions, , ¢ Multiple Choice Questions, 1. What will be the output of the following Python, , , , code snippet?, , dl = {“Neha”:86, “Yash”:92}, d2 = {“Neha”:86, “Yash”:88), , dl > d2, , (a) True (b) False, , , , (©) Error (@) None, , Ans. (c) Arithmetic operator ‘>’ cannot be used with dictionaries., , 2. What will be the output of the following Python, , code?, Dicl=(}, Dicl[2]=85, Dicll1J=[22, 23,24], print (DiclC1]£1]), (a) [22,23,24] (b) 23, (0) 22 (@) Error, , Ans. (b) Now, Dicl={2 : 85, 1: [22, 23, 24]}. Dicl[1][1] refers to, second element having key on position 1, ie. 23,, , 3. What will be the output of the following Python, code?, , dicl = ‘One’,, for x, y in dicl:, Print(x, y), (a)012 (b) One Two Three, ()0One1Two2Three () Error, , Ans. (d) It will give Error, because objects of type int are not, iterable., , 4. What will be the output of the following Python, , code snippet?, d=(“Neha” : 140, “Paras” : 145}, print(list(d.keys())), (a) [“Neha”, “Paras”], (b) ["Neha” : 140, “Paras” : 145], (c) ("Neha”, “Paras”), (€) ("Neha” : 140, “Paras” : 145), , Ans. (a) The output of the code is a list, the dictionary d, wit, , , , B1Wosmness Tihnees), , , , containing only k, f, ith the help of d.keys() mbthiod. Tae, , , , , , CBSE Term 11 |, , , , , , 11. Keys ofa, , (a) mut:, , i t of the following Python (6) Both (a, , . What will be the outpu i, 5 ie snippet? Ans. () Keys of, , , , , , , , , , , , , , , , , , , , , , : ee ‘ data typ, dicl={1: ‘One’. 2: ‘Two’, 3: ‘Three:) they cannc, diel Wags key-value’, Paine en ae )) se (a2 12. Diction, , Ans. In the second line obese, heieten becomes an a es, empty dictionary: Thus, length & ‘ 5 Ans. (d) Dictior, , 6. What is the output of following code? associa, dicl ={115'12) 13} values that, ata ieee ocr as an elem, , - es things you, print (7), (a) 11 12 13 13258 met, (b) {11, 12, 13}{11, 12, 13} {11, 12, 13} value fror, (c) Error (a) del(), (d) None (©) pop(), 7. What is the output of following code? Ans. ‘elpen) a, i ‘, 22? qc ASU On@ ra By as ai” , ' key. If spec, Three’ } and returns, on dic.keys ( ) throws an «, a) [B’,‘C’,, ‘A’] (b) dict_keys [(‘B’, ‘C’, ‘ ., (©) dict_keys ((‘B’, ‘C’, ‘A’]) _ (d) keys ((‘B, ‘C, ‘A’)) a a, , Ans. (c) keys() returns a view object that displays a list of al aout, keys in the dictionary, (a) items(), In given dictionary, A, B, C are keys, while One, Two, Th {c)clesni), are values. Ans. (b) get() me, , present in t, , 8. Which one of the following is correct? Syntax dic, (a) In Python, a dictionary can have two s: ke ith, , different values. baiothe fa 15: aoe ie, (b) In Python, a dictionary can have two s I ith ae, different keys ee ©),, (c) In Python, a dictionary can have two same keys or sat Ans. (b) Each ke, values but cannot have two same key-value pair. () whereas, (d) In Python, a dictionary can neither have two same ke) 16. A dictiona, nor two same values. he |, , Ans. (b) In Pytho di eae, ; ython, a dictionary can have two same values wi (a) map, different keys, , ; (©) Both (a), , = d1={ abe":5, “def” :6, “ghi":7} Ans. (b) A dictior, Print(d1[0}) to store the, ee will be the output of above Python code? e eae is, , ‘a (b)5 (©) (“abe”:5} (qd) Error fife, , Ss. (d) The given cod, will | (a), nein aie oe show an error. Because 0 is nee (<>, , onary abe, def and ghi considered as keys"