Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Bharat International Senior Secondary School (CBSE),KRISHNAGIRI.

Affiliated to CBSE New Delhi – 1930502


Daily Test
CLASS:XII MARKS: 70
SUBJECT: INFORMATICS PRACTICES
DATE:21.08.2023

I. Multiple Choice Questions (1x5=5)

1. Which of the statement(s) is/are correct?


(i) In Python dictionary, the key-value pair is called an item.
(ii) Python dictionary is a mapping of unique keys to values.
(iii) Dictionary is mutable.
(iv) All of the above.
2. To create an empty dictionary, we use the statement as:
(i) d1={} (ii) d1=[]
(iii) d1=() (iv) d1=={}
3. In a dictionary, the elements are accessed through:
(i) key (ii) value
(iii) label (iv) None of these
4. Keys of a dictionary must be:
(i) Similar (ii) Unique
(iii) Both (i) and (ii) (iv) All of these

5.To create a new dictionary with no items:


(i) Dict (ii) dict()
(iii) d1={} (iii) Both (i) and (ii)

II. Short answer questions


1. What is a dictionary?

2. How are objects stored in dictionaries different? Ans. The objects or values stored in a dictionary
can be of any data type (even the type NONE) but keys can b immutable type-objects, e.g., strings,
integers, etc.

[HOTS

3. Write a code to create an empty dictionary.

Ans, >>> d1= [F


OR

>>> di = dict()

>>> print (dl)

4. Can sequence operations such as slicing and concatenation be applied to dictionaries? Why/Why
not? [HOTS

Ans. No, sequence operations such as slicing and concatenation cannot be applied to dictionaries as
dictionary is not a sequence. Since they are not maintained in any specific order or we may say
arranged in the order of insertion, operations that depend on a specific order cannot be used.
However, we can use some dictionary methods to achieve similar functionality. For example,
items() functions returns a sequence-like object that can be iterated over, sliced and concatenated.

5. Why can't lists be used as keys?

[HOTS] Ans. Lists cannot be used as keys in a dictionary because they are mutable and a Python
dictionary can have only

keys of immutable types. 6. If the addition of a new key-value pair causes the size of the dictionary
to grow beyond its original size, it

shall result in an error. True or false? [HOTS Ans. False. No error shall occur because dictionaries
are mutable in nature and they can grow or shrink as and when required.

7. What are the differences between lists and dictionaries?

Ans. In list, elements are enclosed within square brackets whereas in dictionary key-value pairs are
enclosed within curly braces. In dictionary, index value can be of any data type (except list) and is
called key. but in list, index value is an integer. (2x2=4)
III. Explain the following (4x4=16)
1. Suppose L = [“These”,”are”,”a”,[“few”,”word”],”that”,”we”,”will”,”use”]
consider the above list and answer the following:
a) L[3:4]
b) L[3:4][0][1]
c) L[0::2]
d) L[4:]

2. What will be the output of following code:


a) list1=[12,32,65,26,80,10]
list1.sort()
print(list1)
b) list1=[12,32,65,26,80,10]
list2=sorted(list1, reverse=True)
print(list2)
c) list1=[1,2,3,4,5,6,7,8,9,10]
list1[::-2]
print(list 1[:3]+list1[3:])
d) list1=[1,2,3,4,5]
print(list[len(list1)-1]

3. Write a python code to find atleast one common element amongst the two inputted list.
4. Explain about different built-in functions in the list.

You might also like