Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a function called allButMaxthat expects no arguments. Instead, this function gets its input from the user at the keyboard. The function asks the user

Create a function called allButMaxthat 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 endto 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.0

50.0

>>> 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.0

12.0

>>> 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

>>> allButMax()

Enter next number: end

The sum of all values except for the maximum value is: 0

0

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

More Books

Students also viewed these Databases questions