233k views
3 votes
Given that d refers to a dictionary, change the value mapped to by the key 'Monty' to 'Python'. Write in Python

User Palo
by
6.8k points

2 Answers

1 vote
>>> d = {}
>>> d[ "Monty" ] = "Python"
>>> d
{'Monty': 'Python'}


User Ferit
by
7.2k points
7 votes

Answer:

The program to this can be given as:

Program:

d = {} #defining a dictionary.

d[ "Monty" ] = "Python" # assigning a value

#d={' Monty ': ' Python '}

print (d) #print value.

Output:

{'Monty': 'Python'}

Step-by-step explanation:

Dictionary is an unordered data collection that is as opposed to other data types. In dictionary is a collection key and values. The key is a value that is pair as an element and value are stored in a map. The explanation of the above python program can be described as follows:

  • In the above python program, a dictionary d is defined that contains a value that is Monty which is also known as dictionary key value.
  • In the key-value we assign a value that is "Python". and print the value of the dictionary.
  • To print dictionary value the print function is used.

User Jvrdelafuente
by
7.3k points