कोड की कौन सी पंक्ति 'grapes' की key और 15 के value के साथ fruits dictionary में एक आइटम को सही ढंग से जोड़ती है?
Which line of code correctly adds an item to the fruits dictionary with a key of ‘grapes’ and a value of 15?
fruits = {'apples': 1, 'bananas': 4, 'pears': 17, 'oranges': 14}
A)
B)
C)
D)
Explanation:
To add an item to the fruits
dictionary with the key 'grapes'
and the value 15
, you should use the following syntax:
fruits['grapes'] = 15
This correctly adds the key 'grapes'
with the value 15
to the dictionary.
Answer: (B) fruits['grapes'] = 15