Computer Science, asked by abhisheksaxenasinggh, 4 months ago

Suppose Dic1={1:’south’,2:’ponit’,3:’school’}

Dic2={‘one’:’CBSE’,’two’=’Guwahati’}

Write the output of the following code: 3

i. print( Dic1.items())

ii. print( Dic2.keys())

iii. print( Dic1.values())

iv. print( Dic1.update(Dic2))

v. print( len(Dic2))

vi. Dic2.clear()​

Answers

Answered by BrainlySmile
9

Answer- The above question is from the chapter 'Working With Lists and Dictionaries'.

Python-

Python is a simple programming language.

It has been created by Guido van Rossum and launched in 1991.

Its features make it easy to understand and this language is used a lot in the big companies and industries.

Given question: Suppose Dic1 = {1 : "south", 2 : "point", 3 : "school"}

Dic2 = {"one" : "CBSE", "two" : "Guwahati"}

Write the output of the following code:

i. print(Dic1.items())

ii. print(Dic2.keys())

iii. print(Dic1.values())

iv. print(Dic1.update(Dic2))

v. print(len(Dic2))

vi. Dic2.clear()​

print(Dic2)

Answer:

Dic1 = {1 : "south", 2 : "point", 3 : "school"}

Dic2 = {"one" : "CBSE", "two" : "Guwahati"}

i. >>> print(Dic1.items())              #It will display key-value pairs in Dic1.

dict_items([(1, 'south'), (2, 'point'), (3, 'school')])

ii. >>> print(Dic2.keys())             #It will display only keys in Dic2.

dict_keys(['one', 'two'])

iii. >>> print(Dic1.values())          #It will display only values in Dic1.

dict_values(['south', 'point', 'school'])

iv. >>> print(Dic1.update(Dic2))  #It will update elements of Dic2 in Dic1.

{1: 'south', 2: 'point', 3: 'school', 'one': 'CBSE', 'two': 'Guwahati'}

v. >>> print(len(Dic2))                 #It returns the length of Dic2.

2

vi. >>> Dic2.clear()​

>>> print(Dic2)                            #It displays an empty Dic2.

{ }

(Note: Output has been displayed using Heading font size. Comments have been added for lucid explanation.)

Similar questions