
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.
so when I call my function, I get "Average is 110" but I need to get rid of quotation marks and have dot at the end like sample s Avarge is 110.
![In [69]: #todo
def task8(dict_in):
# YOUR CODE HERE
S=0
c=1
for i in dict_in.values():
S+=i
C+=1
avg=(int(s/(c-1))
str_out="Average is "+str(avg)+"."
return str_out
Input In [69]
str_out="Average is "+str(avg)+"."
A
SyntaxError: invalid syntax
In [68]: assert task8({'Jon': 100, 'Dan':200,
assert task8({'Jon': 100, 'Dan' :200,
'Rob':30, 'Ned':110})
'Rob':300})
==
In [71]: task8({'Jon': 100, 'Dan':200, 'Rob':30, 'Ned': 110})
Out [71]: 'Average is 110¹
==
"Average is 110."
"Average is 200."
AssertionError
Traceback (most recent call last)
Input In [68], in <cell line: 1>()
----> 1 assert task8({'Jon': 100, 'Dan':200, 'Rob':30, 'Ned' :110})
2 assert task8({'Jon': 100, 'Dan':200, 'Rob' :300}) "Average is 200."
AssertionError:
==
=
"Average is 110."](https://content.bartleby.com/qna-images/question/a1d592a5-ec96-4b1d-bddf-23e27014debe/33ac6441-c08b-4997-b2d7-273b52bcca3b/t81xhbt_thumbnail.png)

Step by stepSolved in 2 steps with 1 images

- ????????:Write a Python program that takes a list and a step size(integer number) as inputs from the user. Your program should swap elements from the front and back while maintaining the step size.[You are not allowed to use built-in replace() function]================================Sample Input 1:A,B,C,D,E,F,G,H2Sample Output 1:Before swap: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']After swap: ['H', 'B', 'F', 'D', 'E', 'C', 'G', 'A']Explanation 01:Here in the input, a list is given as input, and 2 is the step size. ‘A’(index0) swaps places with ‘H’(index -1). Then step size increments by 2. 0+2= 2. Swapping starts from index2. ‘C’(index2) swaps places with ‘F’(index -3).================================Sample Input 2:A,B,C,D,E,F,G,H5Sample Output 2:Step size is not suitableExplanation 02:Here in the input, a list is given as input, and 5 is the step size which is greater than half of the list length. So swapping is not possible.================================Sample Input…arrow_forwardQuestion 1: Write a python program that will take an input n from the user and then take n number of circle's radius input from the user. After that your program will calculate the area and circumference of the circle and store it in a dictionary where a key will be the circle number and value will be a list containing area first and then circumference of that circle. Finally print the dictionary. Area of circle = pi * r *r Circumference of circle = 2 * pi *r Sample input 1: 2 4 Sample Output 1: {'Circle 1': [12.566370614359172, 12.566370614359172], 'Circle 2': [28.274333882308138, 18.84955592153876], 'Circle 3': [50.26548245743669, 25.132741228718345]} Sample input 2: 4 2 3 1 Sample Output 2: {'Circle 1': [12.566370614359172, 12.566370614359172], 'Circle 2': [113.09733552923255, 37.69911184307752], 'Circle 3': [28.274333882308138, 18.84955592153876], 'Circle 4': [3.141592653589793, 6.283185307179586]}arrow_forwardSort Realize direct insertion sort, half insertion sort, bubble sort, quick sort, select sort, heap sort and merge sort. Raw data is generated randomly. For different problem size, output the number of comparisons and moves required by various sorting algorithms When the program is running, input the problemsize from the keyboard, the source data is randomly generated by the system, and then output the comparison times and movement times required by various sorting algorithms under this problem scale.. Do this in C language..the attached picture is just to show you how the program should bearrow_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





