Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In [ ]: Write a function that takes two arguments, an array of day-of-week numbers and an array of rainfall amounts and returns the

 

In [ ]: Write a function that takes two arguments, an array of day-of-week numbers and an array of rainfall amounts and returns the midweek and weekend average rainfall as defined by the NASA researchers. Remember to check how you are supposed to define weekend and mid-week. Remember, you can return multiple results by packing them into a tuple. I strongly recommend using numpy array boolean functions to group your days into midweek and weekend; looping is likely to be too slow when you call your function thousands of times in the next part. You should not write a for loop that tests if each item! 1 #Put the code for your function here. 2 3 #now call your function and store the returned values in variables midwk 4 #and wkend 5 midwk = 0 6 wkend = 0 7 #then compute their difference in variable delta 8 delta midwk - wkend 9 10 11 print ('It rained', midwk, 'inches mid week'). 12 print('It rained', wkend, 'inches weekend'). 13 print('Difference was', delta, 'inches').

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

C++ Primer Plus

Authors: Stephen Prata

6th Edition

978-0321776402, 0321776402

Students also viewed these Algorithms questions