Question: Please write in Python 3 1. Write a function threshold(values, goal) that behaves as follows. The first parameter is a sequence of numbers. The second

Please write in Python 3

Please write in Python 3 1. Write a function threshold(values, goal) that

1. Write a function threshold(values, goal) that behaves as follows. The first parameter is a sequence of numbers. The second parameter is a single positive number. The function is to return the smallest possible integer n such that the sum of the first n numbers in the sequence is greater than or equal to goal. For example, threshold ([5, 3, 8, 2, 9, 1], 17) should return 4 because the goal can be achieved by the sum of the first four values (5+3+8+2) If the goal is unachievable, the function should return 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!