Page 228 - Information_Practice_Fliipbook_Class11
P. 228
1. Assertion(A): Dictionary is an unordered data type.
Reasoning (R): The key-value pairs in a dictionary are accessed using keys as indexes.
2. Assertion(A): Python does not allow modification of keys in a dictionary.
Reasoning (R): Keys are used to retrieve the corresponding key-value pairs in a dictionary.
Case-based Questions
1. Abhilasha wants to create a program for her younger sister who is learning spellings of each digit. She wants to create a
dictionary that stores a digit and its corresponding spelling as key-value pairs. So, the dictionary will have items as 1:"One",
2:"Two, 3:"Three", …, 9:"Nine". Further, she wants to develop a program to accept a number as input and then display the
spellings for its digits. For example, if the user enters 502, the output should be Five Zero Two
2. Sukrit is a programmer in an IT company. He has been assigned the task of creating a Python program that will accept the
name and date of birth of each employee as input and store name and date of birth as key-value pairs of a dictionary. Sukrit
wishes to display the data of the employees ordered with respect to their names arranged in alphabetical order. Help him
to complete the task.
NCERT Exercise Solutions
1. What will be the output of the following statements?
a. list1 = [12,32,65,26,80,10]
list1.sort()
print(list1)
b. list1 = [12,32,65,26,80,10]
sorted(list1)
print(list1)
c. list1 = [1,2,3,4,5,6,7,8,9,10]
list1[::-2]
list1[:3] + list1[3:]
d. list1 = [1,2,3,4,5]
list1[len(list1)-1]
Ans. a. [10, 12, 26, 32, 65, 80]
b. [10, 12, 26, 32, 65, 80]
[12, 32, 65, 26, 80, 10]
c. [10, 8, 6, 4, 2]
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
d. 5
2. Consider the following list myList. What will be the elements of myList after each of the following operations?
myList = [10,20,30,40]
a. myList.append([50,60])
b. myList.extend([80,90])
Ans. a. [10,20,30,40,[50,60]]
b. [10,20,30,40,[50,60],80,90]
3. What will be the output of the following code segment?
myList = [1,2,3,4,5,6,7,8,9,10]
for i in range(0,len(myList)):
if i%2 == 0:
print(myList[i])
Ans. Above code print even positioned element of myList.
1
214 Touchpad Informatics Practices-XI

