Question

In python coding please add functions/methods at least 3 of them. Please just adjust code I...

In python coding please add functions/methods at least 3 of them. Please just adjust code I have provided and update it to include functions/methods. You can rearrange the code, edit or delete parts to add functions/methods. PLEASE DO NOT make a Whole New code. Please use what I have provided. I do not need a whole different code, just edits on what I have provided.

THIS is the original question:Design a modular 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, the total trimester amount, the total semester amount and the total annual cost of these expenses.

#read all the expenses
loanPayment=float(input("Enter Monthly loan Amount "))
insuranceAmount=float(input("Enter Monthly Insurance Amount "))
gasAmount=float(input("Enter Monthly Gas Amount "))
oilAmount=float(input("Enter Monthly Oil Amount "))
tiresAmount=float(input("Enter Monthly tires Amount "))
# add the all the expenses to get the total expenses of one month
totalExpenditures=loanPayment+insuranceAmount+gasAmount+oilAmount+tiresAmount
# print expenses for one month
print("Monthly expenses ",totalExpenditures)
#print expenses for 3 months by multiplying monthly expenses by 3
print("Expenses for trimester ",totalExpenditures*3)
#print expenses for 6 months by multiplying monthly expenses by 6
print("Expenses for Semester ",totalExpenditures*6)
#print expenses for 12 months by multiplying monthly expenses by 12
print("Annual Expenses ",totalExpenditures*12)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Python Code for the above problem-

#function to calculate totalExpenditures
def calculate_totalExpense(loanPayment,insuranceAmount,gasAmount,oilAmount,tiresAmount):
totalExpenditures=loanPayment+insuranceAmount+gasAmount+oilAmount+tiresAmount
return(totalExpenditures)

#function to calculate Expenses for trimester
def calculate_trimester(totalExpenditures):
return(totalExpenditures*3)

#function to calculate Expenses for Semester
def calculate_semester(totalExpenditures):
return(totalExpenditures*6)

#function to calculate Annual Expenses
def calculate_annual(totalExpenditures):
return(totalExpenditures*12)

#read all the expenses
loanPayment=float(input("Enter Monthly loan Amount "))
insuranceAmount=float(input("Enter Monthly Insurance Amount "))
gasAmount=float(input("Enter Monthly Gas Amount "))
oilAmount=float(input("Enter Monthly Oil Amount "))
tiresAmount=float(input("Enter Monthly tires Amount "))
# add all the expenses to get the total expenses of one month
totalExpenditures=calculate_totalExpense(loanPayment,insuranceAmount,gasAmount,oilAmount,tiresAmount)
# print expenses for one month
print("Monthly expenses ",totalExpenditures)
#print expenses for 3 months by multiplying monthly expenses by 3
print("Expenses for trimester ",calculate_trimester(totalExpenditures))
#print expenses for 6 months by multiplying monthly expenses by 6
print("Expenses for Semester ",calculate_semester(totalExpenditures))
#print expenses for 12 months by multiplying monthly expenses by 12
print("Annual Expenses ",calculate_annual(totalExpenditures))

Code-
#function to calculate total Expenditures def calculate_totalExpense(loanPayment, insuranceAmount, gasAmount,oilAmount, tires
Input and Output-
Enter Monthly loan Amount 200 Enter Monthly Insurance Amount 300 Enter Monthly Gas Amount 500 Enter Monthly Oil Amount 120 En


If the answer helped then please upvote, it means a lot.
And for any queries feel free to comment.

Add a comment
Know the answer?
Add Answer to:
In python coding please add functions/methods at least 3 of them. Please just adjust code I...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Design a modular program that asks the user to enter the monthly costs for the following...

    Design a modular 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, the total trimester amount, the total semester amount and the total annual cost of these expenses. Submission should have: Source Code in PY format (No accepted screenshots of source code anymore) It should contain proper indentation...

  • MATLAB!!! CAN SOMEONE SOLVE THIS PROBLEM ON MATLAB?? THANK YOU PART B: HOUSING LOAN CALCULATOR In this part of the assignment, you are expected to develop a program that calculates housing loan pay-...

    MATLAB!!! CAN SOMEONE SOLVE THIS PROBLEM ON MATLAB?? THANK YOU PART B: HOUSING LOAN CALCULATOR In this part of the assignment, you are expected to develop a program that calculates housing loan pay- ments based on compound interest formulas The program should prompt a user to input the amount borrowed (principal), p, the number of monthly payments, n, and an annual interest rate in R percent. The program should convert the annual interest rate R into a monthly interest rate...

  • New to python if you can add screenshort also, i am using python 3 7.3 (The...

    New to python if you can add screenshort also, i am using python 3 7.3 (The Account class) Design a class named Account that contains A private int data field named id for the account. A private float data field named annualInterestRate that stores the current A constructor that creates an account with the specified id (default 0), initial The accessor and mutator methods for id, balance, and annualInterestRate A private float data field named balance for the account. interest...

  • Using Python 3, is there a way I could find the second_highest value of a user's...

    Using Python 3, is there a way I could find the second_highest value of a user's random input using a while-loop? For example, if I use random input numbers such as: 100,95,92,87,83,80,75,50,40 etc. I want it to compute the 2nd highest along with my highest and lowest score. Is there any if, else, elif, etc statement that I could add to my while statement or in my while-loop to make this happen? The output would be something like highest =...

  • Write a python program where you create a list (you an create it in code you...

    Write a python program where you create a list (you an create it in code you do not have to use input() statements) that represents the total rainfall for each of 12 months (assume that element 0 is January and element 11 is December). The program should calculate and display the: 1) total rainfall for the year; 2) the average monthly rainfall; 3) the months with the highest and lowest amounts. You need to figure out how to access each...

  • python 3 8.12 LAB: Python cross reference In addition to editors and compilers, a software developer...

    python 3 8.12 LAB: Python cross reference In addition to editors and compilers, a software developer may use tools to analyze the software they are writing to examine the names being used for variables and functions, and list the line numbers where the variables and functions names appear. For example, consider the following program savings.py used to compute the month to month interest gained from a certificate of deposit: 1: Input the CD APR, no years and initial deposit 2:...

  • using this code to complete. it python 3.#Display Program Purpose print("The program will show how much...

    using this code to complete. it python 3.#Display Program Purpose print("The program will show how much money you will make working a job that gives a inputted percentage increase each year") #Declaration and Initialization of Variables userName = "" #Variable to hold user's name currentYear = 0 #Variable to hold current year input birthYear = 0 #Variable to hold birth year input startingSalary = 0 #Variable to hold starting salary input retirementAge = 0 #Variable to hold retirement age input...

  • In Python please. Problem 3 (Tracking Stock Levels) For this third part, you will add functionality to track stock level...

    In Python please. Problem 3 (Tracking Stock Levels) For this third part, you will add functionality to track stock levels within the store and prevent customers from placing orders that cannot be fulfilled. Again, copy your solution from the previous problem into a new file called a2p3.py. Do not overwrite your previous solution, as the TAs will want to see them both. Modify your code by adding a new variable to keep track of the stock level of each product...

  • Please I wish you use Python 3.7 for this problems. Q1. Write a program that receives...

    Please I wish you use Python 3.7 for this problems. Q1. Write a program that receives a series of numbers from the user and allows the user to press the enter key to indicate that he or she is finished providing inputs. After the user presses the enter key, the program should print the sum of the numbers and their average. Q2. The credit plan at TidBit Computer Store specifies a 10% down payment and an annual interest rate of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT