Question: Consider the following simple program and note how repetitive it is to prompt for the inputs. ` ` ` def main ( ) : price
Consider the following simple program and note how repetitive it is to prompt for the inputs.
def main :
price floatinputFirst item:
print
price floatinputNext item:
print
rate floatinputTax rate in percent:
total price price
tax total rate
printAmount due:", total tax
Rearrange these lines of code into an alternate solution with a reusable helper function. Put the helper function after main and be sure to call the main function after the helper function definition. Empty print statements are included for output formatting.
How to use this tool
Unused
tax total rate
rate readFloatTax rate in percent"
print
price readFloatFirst item"
print
return value
price readFloatSecond item"
print
value floatinputprompt :
total price price
printAmount due:", total tax
def readFloatprompt :
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
