Below you are given the algorithms for two functions, main and doMath. Implement both in Python. function
Fantastic news! We've Found the answer you've been seeking!
Question:
Below you are given the algorithms for two functions, main and doMath. Implement both in Python.
function main():
get x from user
get y from user
call doMath(x,y)
function doMath(lhs, rhs):
sum = lhs + rhs
diff = lhs – rhs
product = lhs x rhs
quotient = lhs / rhs
display sum, diff, product, and quotient on separate lines
Part 2
Add a new function called get_fuel to your Python program.
calc_fuel which takes two input parameters:
distance fuel_consumption.
The function should calculate :
fuel_needed = distance * fuel_consumption / 100.
The function should then return fuel_needed.
Now add the following lines at the end of main():
distance = 500
fuel_rate = 8
fuel = get_fuel(distance, fuel_rate)
print(“Fuel needed is“, fuel)
Related Book For
Posted Date: