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 building a tik tac toe board using python and the function I am using...
I am building a tik tac toe board using python and the function I am using is not working to check to see if the board is full. I'll include the code for the board and the function to check if it is full. X's and O's are being inserted and the function is suppose to stop running when is_full(board) returns True. ch is either x or o board = []    for i in range(3):     board.append([])     for j...
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...
Using Python Define a Student class. A Student class needs to have two attributes, the student_name...
Using Python Define a Student class. A Student class needs to have two attributes, the student_name and strudent_grade . It also has three methods as follows: set_grade(grade) that sets the grade of the student. get_grade returns the grade of the student. print_student_info that print the name and grade of student in a formatted string. In the math_utils.py file define a function called average_grade(roster) . This method accepts as input a list of Student Objects and returns the average of the...
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:)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT