
Write a Python program that takes a dictionary as an input from the user and then prints the average of all the values in the dictionary.
[You are not allowed to use len() and sum()]
===================================================================
Hint (1): For taking dictionary input
Approach(1): For taking dictionary as an input from the user, you may take the whole dictionary as a string using the input() function. Then you can use the split(), strip() functions and conditions to get the keys and values from the string. Finally, you can make the dictionary using the obtained data.
Approach(2): If the first approach seems too difficult you can create an empty dictionary and then just run a simple loop. For each iteration ask the user for a key and a value using the input() function and keep updating the dictionary with the key and value.
Hint (2): After you have a dictionary, you can use dictionary functions to get all the values from it, run loop to calculate the sum and the total number of values in the dictionary in order to find out the average.
===================================================================
Sample Input 1:
{'Jon': 100, 'Dan':200, 'Rob':300}
Sample Output 1:
Average is 200.
===================================================================
Sample Input 2:
{'Jon': 100, 'Dan':200, 'Rob':30, 'Ned':110}
Sample Output 2:
Average is 110.
![Write a Python program that takes a dictionary as an input from the user and then prints the average of all the values in the dictionary.
[You are not allowed to use len() and sum0]
======ニニ=
ニニニニニ======
Hint (1): For taking dictionary input
Approach(1): For taking dictionary as an input from the user, you may take the whole dictionary as a string using the input) function. Then you can use the split), strip) functions and conditions to get the keys and values
from the string. Finally, you can make the dictionary using the obtained data.
Approach(2): If the first approach seems too difficult you can create an empty dictionary and then just run a simple loop. For each iteration ask the user for a key and a value using the input) function and keep updating
the dictionary with the key and value.
Hint (2): After you have a dictionary, you can use dictionary functions to get all the values from it, run loop to calculate the sum and the total number of values in the dictionary in order to find out the average.
Sample Input 1:
{'Jon': 100, 'Dan':200, 'Rob':300}
Sample Output 1:
Average is 200.
Sample Input 2:
{'Jon': 100, 'Dan':200, 'Rob':30, 'Ned':110}
Sample Output 2:
Average is 110.](https://content.bartleby.com/qna-images/question/3e707fc0-cb46-43b9-93d5-442ff5362392/f2c293af-5849-4563-84fc-22a1ab77b073/0dr757_thumbnail.png)

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- In C++, write a program that reads in an array of type int. You may assume that there are fewer than 20 entries in the array. The output must be a two-column list. The first column is a list of the distinct array elements and the second column is the count of the number of occurences of each element.arrow_forwardPython I have a text file I need to input that has all the States and their capitals laid out like this. New York Albany Georgia Atlanta Then I need to put them into a dictionary using a while loop. I'm having trouble figuring out how to make the state a key and the capital a value in the dictionary. This is the request from the proffessor. Remember the state name is on one line, and the capital is on the following line, so it makes sense to read the file using a while loop. The file reader steps look like this. Define & initialize your variables Open the file Read the first line to get a state While the state is not EOF Read the following line to get capital Strip off the EOL characters Stuff capital into a dictionary using the state as key Read next state Close the file Return the dictionary variablearrow_forwardUsing c++ Contact list: Binary Search A contact list is a place where you can store a specific contact with other associated information such as a phone number, email address, birthday, etc. Write a program that first takes as input an integer N that represents the number of word pairs in the list to follow. Word pairs consist of a name and a phone number (both strings). That list is followed by a name, and your program should output the phone number associated with that name. Define and call the following function. The return value of FindContact is the index of the contact with the provided contact name. If the name is not found, the function should return -1 This function should use binary search. Modify the algorithm to output the count of how many comparisons using == with the contactName were performed during the search, before it returns the index (or -1). int FindContact(ContactInfo contacts[], int size, string contactName) Ex: If the input is: 3 Frank 867-5309 Joe…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





