Computer Science, asked by sagardambal123, 3 months ago

output of :

a={1:"A",2:"B",3:"C"}

print(a.get(1,4))

Answers

Answered by anindyaadhikari13
2

Required Answer:-

Given Co‎de:

a={

   1:"A",

   2:"B",

   3:"C"

}

print(a.get(1,4))

Output:

>> A

Explanation:

  • The get() method returns the value of the item with specified key.
  • Syntax: dictionary.get(keyname,value).
  • Here, keyname is 1 and the value is 4.
  • So, the get() method returns the value in the dictionary whose key us 1 i.e., it returns the value - "A".
  • The second parameter is an optional parameter. If the keyname is not in the dictionary, the get() method returns the value written in the second parameter.
  • As we can see that the keyname '1' is present in the dictionary, the get() returned "A" which is displayed on the screen.

See the attachment for output.

Attachments:
Similar questions