Computer Science, asked by roshanmatziii, 1 month ago

Consider a dictionary ODD of odd numbers between 1 and 10, where the key

is the decimal number and the value is the corresponding number in words.

Perform the following operations on this dictionary.

ODD={1:'One',3:'Three',5:'Five',7:'Seven',9:'Nine'}

a) Display the keys

b) Display the values

c) Display the items

d) Find the length of the dictionary

e) Check if 7 is present or not

Answers

Answered by anindyaadhikari13
7

Required Answer:-

Given Dictionary:

ODD={1:'One',3:'Three',5:'Five',7:'Seven',9:'Nine'}

1. To display the keys.

  • Códe: print(ODD.keys())

2. To display the values.

  • Códe: print(ODD.values())

3. To display the items.

  • Códe: print(ODD.items())

4. To Display length of dictionary.

  • Códe: print(len(ODD))

5. To check and display if 7 is present or not.

  • Códe: print(7 in ODD.keys())

Explanation:

  1. keys():- This function is used to display the keys of the dictionary.
  2. values():- This function is used to display the values of dictionary.
  3. items():- This function is used to display the items of the dictionary.
  4. len():- This function is used to find out the length of any arrays like dictionary, lists, tuples and so on.

Refer to the attachment for output ☑.

Attachments:
Similar questions