Question

In: Computer Science

I am a student taking python programming. Can this problem be modified using the define main...

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)

Solutions

Expert Solution

# 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()


Related Solutions

I am taking physics lab and I can not understand the difference of the sources of...
I am taking physics lab and I can not understand the difference of the sources of errors below: Random error in measurement Random intrinsic error Systematic error in measurement Systematic intrinsic error So, can you explain the difference between them please
Python: I am not sure where to begin with this question, and I hope I can...
Python: I am not sure where to begin with this question, and I hope I can get an input on it. This is in regards to Downey's program, and we are asked to make two changes. Downey prints time as they do in the Army: 17:30:00 hours. We want to print that as 5:30 PM. Downey lets you define the time 25:00:00 - we want to turn over at 23:59:59 to 00:00:00. (I am asked to identify my changes with...
A patient tells the nurse, “Now that I am taking ezetimibe, I can eat anything I...
A patient tells the nurse, “Now that I am taking ezetimibe, I can eat anything I want.” How should the nurse respond?
I am a doctorate student (Educational Leadership) taking a course in School Finance. Please give me...
I am a doctorate student (Educational Leadership) taking a course in School Finance. Please give me questions that I can ask in an interview with a CFO/Treasurer of a school or university finance officer. Thanks.
I am having a trouble with a python program. I am to create a program that...
I am having a trouble with a python program. I am to create a program that calculates the estimated hours and mintutes. Here is my code. #!/usr/bin/env python3 #Arrival Date/Time Estimator # # from datetime import datetime import locale mph = 0 miles = 0 def get_departure_time():     while True:         date_str = input("Estimated time of departure (HH:MM AM/PM): ")         try:             depart_time = datetime.strptime(date_str, "%H:%M %p")         except ValueError:             print("Invalid date format. Try again.")             continue        ...
Python programming problem! Suppose that there is a json file called data from the desktop. I...
Python programming problem! Suppose that there is a json file called data from the desktop. I want to print the value with the key of "year" and "country". Json file below: { "A":{ "year":11, "grade":A, "country":America}, "B":{ "year":18, "grade":C, "country":England}, "C":{ "year":19, "grade":B, "country":China},} I want a code that I can only replace the name of key from year to grade and the code could be work.
Programming language Python It have to be in Functions with a main function Samuel is a...
Programming language Python It have to be in Functions with a main function Samuel is a math teacher at Hogwarts School of Witchcraft and Wizardry. He loves to give his students multiplication exercises. However, he doesn’t care about the actual operation result but the unit sum of its digits. At Hogwarts School of Witchcraft and Wizardry, they define the unit sum (US) of N as the unit that it is left after doing the sum of all the digits of...
Using Python, I am trying to integrate 'iloc' into the line of code below? This line...
Using Python, I am trying to integrate 'iloc' into the line of code below? This line is replacing all the '1' values across my .csv file and is throwing off my data aggregation. How would I implement 'iloc' so that this line of code only changes the '1's integers in my 'RIC' column? patient_data_df= patient_data_df.replace(to_replace=[1], value ="Stroke") Thank you:)
Can you write this program, but in python, I just wanna see what am I doing...
Can you write this program, but in python, I just wanna see what am I doing wrong. thank you Instructions: The Gas-N-Clean Service Station sells gasoline and has a car wash. Fees for the car wash are $1.25 with a gasoline purchase of $10.00 or more and $3.00 otherwise. Three kinds of gasoline are available: regular at $2.89, plus at $3.09, and super at $3.39 per gallon. User Request: Write a program that prints a statement for a customer. Analysis:...
I am trying to work a statistics problem for decision modeling class. The main question is:...
I am trying to work a statistics problem for decision modeling class. The main question is: Consider the experiment of drawing two cards without replacement from a deck consisting of only the ace through 10 of a single suit (for example, only hearts). Q - Define the event Ai to be the set of outcomes for which the sum of the values of the cards is i (with an ace = 1). List the outcomes associated with Ai for i=...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT