Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

3. What might you have done differently?

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago