In: Computer Science
Write a Python program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile:
Write a function that takes these six items as arguments and computes the total cost of these expenses.
Write a main program that asks the user for these six items and calls your function.
Print total monthly cost and the total annual cost for these expenses.
Your function should not have any input statements or print statements (except for debugging print statements).
Dear Student,
below i have written the complete python code as per the requirement.
=============================================================
Program:
=============================================================
#function to calculate monthly cost
def Calculate_Monthly_Cost(LP, Ins, Gas, Oil, Tires,
Maintenance):
total_monthly_cost = LP + Ins + Gas + Oil +
Tires + Maintenance
return total_monthly_cost
#Accept the values from the user
LP = float(input("Enter the monthly cost of the Loan payment:
"))
Ins = float(input("Enter the monthly cost of the insurence:
"))
Gas = float(input("Enter the monthly gas cost: "))
Oil = float(input("Enter the monthly Oil cost: "))
Tires = float(input("Enter the monthly cost of the tires: "))
Maintenance = float(input("Enter the monthly cost of the
maintenace: "))
#call to main function
if __name__ == "__main__":
Monthly_Cost = Calculate_Monthly_Cost(LP, Ins, Gas, Oil, Tires, Maintenance)
print("Monthly cost is: $",
Monthly_Cost)
print("Annual cost is: $", Monthly_Cost*12)
=============================================================
Screenshot of the program:
=============================================================
Sample Output:
============================================================
Kindly Check and Verify Thanks...!!!