(b) Implement a function in Python to create a dictionary: {'a': 10, 'b': 20, 'c': 30, 'd': 40} and display each key-value pairs of it. Implement a function dict_check_add(dictionary, key, value) in Python to check whether a key of the given key-value pair already exists in the dictionary. If it is not, add the key-value pair to the dictionary.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18PE
icon
Related questions
Question

Been stuck on this question for quite awhile. A detailed explanation will be much appreicated. Will give a like and thank you in advance. 

(b)
Implement a function in Python to create a dictionary: {'a': 10, 'b': 20, 'c': 30, 'd': 40}
and display each key-value pairs of it.
Implement a function dict_check_add(dictionary, key, value) in Python to check
whether a key of the given key-value pair already exists in the dictionary. If it is not,
add the key-value pair to the dictionary.
Transcribed Image Text:(b) Implement a function in Python to create a dictionary: {'a': 10, 'b': 20, 'c': 30, 'd': 40} and display each key-value pairs of it. Implement a function dict_check_add(dictionary, key, value) in Python to check whether a key of the given key-value pair already exists in the dictionary. If it is not, add the key-value pair to the dictionary.
Expert Solution
steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Knowledge Booster
Lists
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning