Define a function called create_numbers_dictionary (numbers) which takes a list of integers as a parameter and creates a dictionary by looping though each element in the list. The function returns the dictionary that records the frequencies of the numbers 1 to 6 (inclusive) appearing in the parameter list. For example: Test Result 11 a_dict = create_numbers_dictionary ([3, 2, 2, 3, 2, 4, 5, 4, 1]) for key in sorted (a_dict): 23 print(key, a_dict [key]) 32 print (type (a_dict)) 42 51 60 a_dict = create_numbers_dictionary ([3, 4, 1, 4, 2, 6, 3, 4, 2, 1]) {1: 2, 2: 2, 3: 2, 4: 3, 5: 0, 6: 1} print(a_dict) print (type(a_dict [2]))

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

Stuck on this Python question, step by satep guide please

Define a function called create_numbers_dictionary (numbers) which takes a list of integers as a parameter and
creates a dictionary by looping though each element in the list. The function returns the dictionary that records the
frequencies of the numbers 1 to 6 (inclusive) appearing in the parameter list.
For example:
Test
Result
11
a_dict = create_numbers_dictionary ([3, 2, 2, 3, 2, 4, 5, 4, 1])
for key in sorted (a_dict):
23
print(key, a dict[key])
32
print (type (a_dict))
42
5 1
60
<class 'dict'>
a_dict
=
create_numbers_dictionary([3, 4, 1, 4, 2, 6, 3, 4, 2, 1]) {1: 2, 2: 2, 3: 2, 4: 3, 5: 0, 6: 1}
<class 'int'>
print(a_dict)
print (type (a_dict[2]))
Transcribed Image Text:Define a function called create_numbers_dictionary (numbers) which takes a list of integers as a parameter and creates a dictionary by looping though each element in the list. The function returns the dictionary that records the frequencies of the numbers 1 to 6 (inclusive) appearing in the parameter list. For example: Test Result 11 a_dict = create_numbers_dictionary ([3, 2, 2, 3, 2, 4, 5, 4, 1]) for key in sorted (a_dict): 23 print(key, a dict[key]) 32 print (type (a_dict)) 42 5 1 60 <class 'dict'> a_dict = create_numbers_dictionary([3, 4, 1, 4, 2, 6, 3, 4, 2, 1]) {1: 2, 2: 2, 3: 2, 4: 3, 5: 0, 6: 1} <class 'int'> print(a_dict) print (type (a_dict[2]))
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Structure
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