In: Computer Science
I am a student taking python programming. Can this problem be modified using the define main method, def main()?
#Define showExspenses function
def showExpenses(loan,insure,gas,oil,tyres,maintenance):
expense=loan+insure+gas+oil+tyres+maintenance
#Print monthly and yearly automobile operating expenses
print("\nTotal Monthly expenses for operating expenses you
entered = ",expense)
print(f"\nTotal Yearly expenses for operating expenses you entered
= 12 *",expense,f"= {expense*12:,}") #yearly expenses
loan=int(input("Enter Loan :"))
insure=int(input("Enter Insurance :"))
gas=int(input("Enter Gas :"))
oil=int(input("Enter Oil :"))
tyres=int(input("Enter Tyres :"))
maintenance=int(input("Enter Maintenance:"))
showExpenses(loan,insure,gas,oil,tyres,maintenance)
# Define showExspenses function def showExpenses(loan, insure, gas, oil, tyres, maintenance): expense = loan + insure + gas + oil + tyres + maintenance # Print monthly and yearly automobile operating expenses print("\nTotal Monthly expenses for operating expenses you entered = ", expense) print(f"\nTotal Yearly expenses for operating expenses you entered = 12 *", expense, f"= {expense * 12:,}") # yearly expenses # write the testing code inside main function def main(): loan = int(input("Enter Loan :")) insure = int(input("Enter Insurance :")) gas = int(input("Enter Gas :")) oil = int(input("Enter Oil :")) tyres = int(input("Enter Tyres :")) maintenance = int(input("Enter Maintenance:")) showExpenses(loan, insure, gas, oil, tyres, maintenance) # call the main function here main()