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 a student taking an introductory Unix / LInux shell programming course and need some...
I am a student taking an introductory Unix / LInux shell programming course and need some help with an assignment. Using the file CISED as input, write the sed command to do the following: Change 2 or more occurrences of g to a single g Add > to beginning of any line that begins with CIS132 Add < to the end of any line that ends in Tux or tux Replace any five to eight digit number with XX For...
This is for Python programming, and I am trying to use 2 for loops to ask...
This is for Python programming, and I am trying to use 2 for loops to ask a slaesperson how many of 5 different items they sold, then the program is to calculate the total dollar amount sold. Formatting and all that aside, I am having an issue with the loops not stepping through the 2 lists at the same time. The first loop is taking all 5 entered quantities times the price of the first item, and then all 5...
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
I am stuck on the following problem please and it has to be in python! 1)...
I am stuck on the following problem please and it has to be in python! 1) Initially, create a list of the following elements and assign the list to a variable "thing". "Mercy", "NYU", "SUNY", "CUNY" 2) print the list above 3) add your last name to the list 4) print the list 5) add the following elements as a nested list to the list: "iPhone", "Android" 6) print the list 7) add the following list to the end of...
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...
I am working on exercise 5.48 from Introduction to Computing using python (Author: Perkovic). Problem Question:...
I am working on exercise 5.48 from Introduction to Computing using python (Author: Perkovic). Problem Question: Let list1 and list2 be two lists of integers. We say that list1 is a sublist of list2 if the elements in list1 appear in list 2 in the same order as they appear in list1, but not necessarily consecutively. For ex, if list1 is defined as [15,1,100] and list2 is defined as [20,15,30,50,1,100]. Then list 1 is a sublist of list 2 because...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT