Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a function that takes as input a single parameter storing a list of integers and returns the average of the negative numbers in the
Write a function that takes as input a single parameter storing a list of integers and returns the average of the negative numbers in the list as a floating point value. The average is calculated by finding the sum of all negative integers in the list divided by the number of negative numbers. Note O is not negative. For example, if the input is the list [1,2,-12,3] then your function should return the float -12 Since the average is -12/1 (as there is only 1 negative number) Or if the input is the list [4,5,6,7,8,9] Then your function should return the float 0 Since there are no negative numbers. Or if the input is the list (-4,-5, -6,7,-8,-9] Then your function should return the float -6.4 since the average is: (-4+-5+-6 +-8 +-9)/5. 1 def get_average(int_list): 2 # your code goes here 3 4 return 5 5 6 if __name '__main_': 7 # you can use this to test your code 8 print(get_average([0,3,-1,10])) 9
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started