The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
I know you already answered this question for me, but my teacher emailed me saying I need to not use min, max or sum because we haven't learned these yet; he wants us to just use loopsÂ
PLEASE HELP HW DUE TOMORROWÂ
How can I redo this problem
Create a function called allButMax that expects no arguments. Instead, this function gets its input from the user at the keyboard. The function asks the user to enter a series of numbers greater than or equal to zero, one at a time. The user types end to indicate that there are no more numbers. The function computes the sum of all the values entered except for the maximum value in the series. (Think of this as dropping the highest homework score from a series of homework scores.) The function then both prints the sum and returns the sum. You may assume the user inputs are valid: they will either be a number greater than or equal to zero, or the string end. Here are some examples of how your function should behave:
>>> allButMax()
Enter next number: 20
Enter next number: 30
Enter next number: 40
Enter next number: end
The sum of all values except for the maximum value is: 50
Â
>>> allButMax()
Enter next number: 1.55
Enter next number: 90
Enter next number: 8.45
Enter next number: 2
Enter next number: end
The sum of all values except for the maximum value is: 12
Â
>>> x = allButMax()
Enter next number: 3
Enter next number: 2
Enter next number: 1
Enter next number: end
The sum of all values except for the maximum value is:Â 3.0
>>> print(x)3.0