1. Please use Python 3 to write the follwing functions: Please do not write by h
ID: 3751396 • Letter: 1
Question
1. Please use Python 3 to write the follwing functions: Please do not write by hand show all outputs and please share code.
2. Please show all outputs.
PLEASE JUST ANSWER #3 BASED ON THE INFORMATION GIVEN BELOW:
problem 3
Rewrite your code from the mortgage calculator from the Python part of Assignment 2 to use functions.
You must use (and call, ha) at least three functions total.
INFROMATION TO ANSWER PART #3 show outputs and please share code
- Mortgage calculator simply stores only necessary information such as the principal amount as balance, monthly_interest. the number of months, interest (of that month) for each month as iteration. In each iteration, we simply update the values of the variables such as balance, month, etc.
- Steps involving in mortgage calculator: (See code for more details)
Step 1: Storing of variables (Such as balance, month, etc.)
Step 2: Iteration loop (Including update information of amount, interest, and months)
Step 3: Printing values in required format i.e.in form of a table.
Python 3 Code: (Runnable and tested on python3.7)
# Python 3 program for mortgage calculator
import sys
import os
balance = 100000
interest_rate = 5.0
monthly_payment = 500
print("month" + " " + "payment" + " " + "interest" + " " + "balance" + " ")
M_value = 99000
month = 0
interest = 0
while(balance > M_value):
interest = balance * (interest_rate / 12)
month += 1
balance = balance + interest - monthly_payment
print(month + " " + monthly_payment + " " + interest + " " + balance + " "
Explanation / Answer
I have convertd your code to complete the requirement. Let me know if you have any doubt. # -*- coding: utf-8 -*- """ Created on Fri Sep 21 18:49:39 2018 @author: """ def input(): balance = 100000 interest_rate = 5.0 monthly_payment = 500 print("month" + " " + "payment" + " " + "interest" + " " + "balance" + " ") return balance,interest_rate,monthly_payment def calculation(balance,interest_rate,monthly_payment): M_value = 99000 month = 0 interest = 0 while(balance > M_value): interest = round(balance * (interest_rate/12),2) month += 1 balance = round(balance + interest - monthly_payment,2) print(str(month) + " " + str(monthly_payment) + " " + str(interest) + " " + str(balance) + " ") def main(): balance,interest_rate,monthly_payment=input() calculation(balance,interest_rate,monthly_payment) main()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.