
Write a Python program that takes a dictionary as an input and then outputs the average of all the values in the dictionary.
[You are not allowed to use len() and sum()]
===================================================================
Hint: 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.
def task8(dict_in):
# YOUR CODE HERE
return str_out
please right the code using dict_in and str_out
result must say Avarage is ....
no print statement can be used

Step by stepSolved in 3 steps with 2 images

- please solve in python and give code. thankzzarrow_forwardWrite a Python program that takes a dictionary as an input and then outputs the average of all the values in the dictionary. [You are not allowed to use len() and sum()] =================================================================== Hint: 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. this is my code but I cant figure out what my mistake is #tododef task8(dict_in): # YOUR CODE HERE values = dict_in.values() i=0 sum=0 for i in values: sum+=i i+=1 av = sum/i str_out = ("Average is" + str(av)) return str_outarrow_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
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





