Question

In: Computer Science

In python, write a program that asked the user to enter the monthly costs for the...

In python, write a program that asked the user to enter the monthly costs for the following expenses incurred from operating his automobile: loan payment, insurance, gas, oil, tires, and maintenance. The program should display total monthly cost and annual cost. Also, should contain main and calcExpenses functions, calcExpenses should only calculate the expenses and everything else should happen in the main function.

Solutions

Expert Solution

Code -

def calcExpenses():
#ask user loan payment cost
loanPayment = float(input("Enter monthly cost for loan payment: "))
#ask user insurance cost
insurance = float(input("Enter monthly cost for insurance: "))
#ask user gas cost
gas = float(input("Enter monthly cost for gas: "))
#ask user oil cost
oil = float(input("Enter monthly cost for oil: "))
#ask user tires cost
tires = float(input("Enter monthly cost for tires: "))
#ask user maintenance cost
maintenance = float(input("Enter monthly cost for maintenance: "))
#calculate the total
total = loanPayment+insurance+gas+oil+tires+maintenance;
#return total
return total
  
if __name__ == '__main__':
#call function calcExpenses and get the total monthly Expenses
monthlyExpenses = calcExpenses()
#print the total Monthly Expenses
print("Total Monthly cost "+str(monthlyExpenses))
#print the Annual cost by multiplying monthlyExpenses by 12
print("Total Annual cost "+str(monthlyExpenses*12))

Screenshots -

pls do give a like , thank you


Related Solutions

In Python write a program that asks the user to enter the monthly costs for the...
In Python write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance the program should then display the total monthly cost of these expenses, and the total annual cost of these expenses. your program MUST have BOTH a main function AND a function named calcExpenses to calculate the expenses. DO NOT display the expenses inside of the calcExpenses function!!...
Write a C++ program that asks the user to enter the monthly costs for the following...
Write a C++ program that asks the user to enter the monthly costs for the following expenses incurred from operating your automobile: loan payment, insurance, gas, oil, tires, and maintenance. The program should then display the total monthly cost of these expenses, and a projected total annual cost of these expenses. Label each cost. The labels should be left aligned and have a column width of 30 characters. The cost should be aligned right and displayed with two decimal places...
Write a program that asks the user to enter the monthly costs for the following expenses...
Write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: Loan payment Insurance Gas Oil Tires Maintenance 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.
Write a program that asks the user to enter the monthly costs for the following expenses...
Write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance. The program should then display the total monthly cost of these expenses, and the total annual cost of these expenses. Using the following test data: 310.34 104.95 78.34 12.34 8.12 45.00 Your output should look like this: Enter the monthly loan payment amount: Enter the monthly cost of insurance:...
Write a program in PYTHON, using a while loop, that asks the user to enter the...
Write a program in PYTHON, using a while loop, that asks the user to enter the amount that they have budgeted for the month. The program should then prompt the user to enter their expenses for the month. The program should keep a running total. Once the user has finished entering their expenses the program should then display if the user is over or under budget. The output should display the monthly budget, the total expenses and whether the user...
(IN PYTHON) Write a program that asks the user repeatedly to enter a student's score or...
(IN PYTHON) Write a program that asks the user repeatedly to enter a student's score or enter -1 to stop. When finished entering all the scores, the program should display the number of scores entered, the sum of the scores, the mean, the lowest and the highest score. (IN PYTHON)
USE PYTHON. Write a program that prompts the user to enter 5 test scores. The program...
USE PYTHON. Write a program that prompts the user to enter 5 test scores. The program should display a letter grade for each score and the average test score. Hint: Declare local variables under main() program Prompts the user to enter 5 test scores Define a function to calculate the average score: this should accept 5 test scores as argument and return the avg Define a function to determine the letter grade: this should accept a test score as argument...
Please write in Python code please: Write a program that asks the user to enter 5...
Please write in Python code please: Write a program that asks the user to enter 5 test scores between 0 and 100. The program should display a letter grade for each score and the average test score. You will need to write the following functions, including main: calc_average – The function should accept a list of 5 test scores as an input argument, and return the average of the scores determine_grade – The function should accept a test score as...
Q2. Design a Pearson modular program that asks the user to enter the monthly costs for...
Q2. Design a Pearson modular program that asks the user to enter the monthly costs for each of the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, and maintenance (create a module for each expense). The program should then display the total monthly cost of these expenses, and the total annual cost of these expenses in the main Module. Use Pass arguments By Reference method to design your modules. Submit your pseudocode with comments at...
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter...
Write a program In python of Jupiter notebook (using loops) that prompts the user to enter his/her favorite English saying, then counts the number of vowels in that (note that the user may type the saying using any combination of upper or lower case letters). Example: Enter your favorite English saying: Actions speak LOUDER than words. Number of wovels: 10
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT