Answered step by step
Verified Expert Solution
Question
1 Approved Answer
python sum In mathematics, the summation operator (commonly written as ) can be used to add up sequences of simple or complicated expressions. It takes
python sum
In mathematics, the summation operator (commonly written as ) can be used to add up sequences of simple or complicated expressions. It takes in a lower bound, upper bound, and a function, then adds up copies of the function with a starting input of the lower bound, incrementing the input by 1 until reaching the upper bound. For example, the summation of from 3 to 6 would be calculated as follows 6 i" = 32 +42 +52 +62 = 86 Your task is to write a function called summation ( that takes in three parameters A lower bound for the summation An upper bound for the summation string, either 'square', 'cube', or 'inverse', specifying the function to be summed A o If this parameter is square', perform a summation of o If this parameter is cube', perform a summation of o If this parameter is 'inverse, perform a summation of Constraints/Comments You should write a main ( ) function to prompt the user for inputs. Ask for a lower bound, an upper bound, and a function name. Then, your main function should call summation () using the given inputs and print out the result. You may assume the upper and lower bounds of the summation will be integers, but make sure you don't divide by zero;) Clarification (2/19): If the user tries to enter any range of numbers that includes 0 and requests the inverse function, print an appropriate error message. You are not required to re-prompt the user You may assume that a valid function name out of the three will be entered However, the parameter specifying the function to be summed must not be case-sensitive Cube', "INVERSE', and 'squArE' should all be valid user inputs You are not allowed to import any modules for this problem An example program output is shown below Enter a lower bound f r summation : 2 Enter an upper bound for summation: 5 Enter a function to be summed (square, cube, inverse): Inverse The result of the summation is 1.2833333333333332Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started