Question: Write a function called calculate that accepts a list of keyword arguments make _ float , a boolean which returns a float if True or

Write a function called calculate that accepts a list of keyword arguments
make_float , a boolean which returns a float if True or an integer if False.
operation which is either 'add', 'subtract', 'multiply', and 'divide'.
first which is a number, second , which is another number, and message which is a string that can be added.
The function should return the result of actually running the specified operation with the first and second keyword arguments. The result of the operation with the first and second is an integer if the make_float keyword argument is False , otherwise the result of the operation is a float. If a message is specified, it should return the message keyword argument + the result of the operation. Otherwise, it should return the string "The result is " joined with the result of the operation. Print
See the code examples for some more information:
calculate(make_float=False, operation='add', message='You just added', first=2, second=4) # "You just added 6"
calculate(make_float=True, operation='divide', first=3.5, second=5) # "The result is 0.7".

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!