Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design and create a Python main program that calls the 3 specified functions and

ID: 3915604 • Letter: D

Question

Design and create a Python main program that calls the 3 specified functions and then run it to test your functions:

A. Write a Python function that receives miles driven and gallons of gas used and returns miles per gallon.

Write Algorithms (Pseudocode) for the program.

B. Write a Python program where the main function uses an input function to get the miles driven (a decimal value) and the gallons of gas used (an integer value), then writes out the miles per gallon, using the function defined above.

Write Algorithms (Pseudocode) for the program.

Note:  Part B has 3 functions -- (1) mile/gallon calculation (Part A), (2) input function, and (3) main function.

Explanation / Answer

def getinput():
   a = float(input("Enter miles:"))
   b = int(input("Enter gallons:"))

   return a,b

def milespergallon(a,b):
    return a/float(b)

def main():
   a,b = getinput()
   print(milespergallon(a,b))

main()

...

Pseudocode for milespergallon

double milespergallon(m,n) // m is miles , n is number of gallons
   calculate avg = m/n
   return avg


Pseudocode for main program

Declare m, n   // m is miles , n is number of gallons
Input miles in m and number of gallons in n by calling m,n = getInput()
Calculate miles per gallon by calling result = milespergallon(m,n)
Display result

'''

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote