Welcome to Westonci.ca, where you can find answers to all your questions from a community of experienced professionals. Get immediate and reliable solutions to your questions from a community of experienced experts on our Q&A platform. Explore comprehensive solutions to your questions from knowledgeable professionals across various fields on our platform.

For this PYTHON lab, we will use functions and imported functions to write a calculation program to do the following:


o Write a program that do the following unit conversion based on user menu selection: (use while

loop until the user enter ‘99’ selection to Quit)

1. Calculate Interest Rate

2. Calculate Mortgage

99 Quit


If user choice selection 1, then calculate interest rate. Modify your interest rate lab program

to be a function. Save this program to simple_interest.py filename in the current lab folder.

Use import to include the function in your main program.

o If user choice selection 2, then calculate mortgage. For this, you need to write a python

program function that will calculate mortgage payment. Save the program to mortgage.py

filename. You can modify the interest program with the following formulate:

1. How to calculate mortgage payment: (You MUST use the following test cases)

 Assume loanAmount = $100,000

 Assume interestRate = 3.25%

 Assume loanTerm = 15 years

 Then formula for mortgage calculation is:

monthlyRate = (interestRate / 100) / 12

numPayments = loanTerm * 12

monthlyPayment = loanAmount * monthlyRate \

* pow((1 + monthlyRate), numPayments) \

/ (pow((1 + monthlyRate),numPayments) - 1)

totalPayment = monthlyPayment * (loanTerm * 12)

interestPaid = totalPayment - loanAmount


 monthlyPayment would be: $702.67

 totalPayment would be: $126,480.38

 interestPaid would be: $26,480.38

PLEASE ANSWER WILL DO ANYTHING WILL MARK BRAINLIEST


Sagot :

Using the computational language in python it is possible to write a code that does the following unit conversion based on user menu selection:

Writing code in python:

def simple_interest(principal,rate,times,year):

       return principal + principal*(rate/times)*(times*year)/100.0

import simple_interest as si

from datetime import datetime

print("CNET-142: Ron Sha, Lab Menu Function\n",datetime.now())

def simpleInterest():

   print("\nCalulating Simple Interest")

   while True:

       principal = float(input("Enter the starting pricipal, <= 0 to quit: "))

       if principal > 0:

           rate = float(input("Enter the annual interest rate: "))

           times = float(input("How many times per year is the interest compounded? "))

           year = float(input("For how many years will the account earn interest? "))

           totalamount = si.simple_interest(principal, rate, times, year)

           print("At the end of ",year," years you will have $ ",totalamount," with interest earned $ ",totalamount-principal)

       else:

           print("Exiting Simple Interest program...")

           break

def mortagePayment():

   while True:

       loanAmount = float(input("Enter the loan amount, 0 to quit: "))

       if loanAmount>0:

           interestRate = float(input("Enter the loan interest rate: "))

           loanTerm = float(input("Enter the loan term (number of years): "))

           monthlyRate = (interestRate/100)/12

           numPayments = loanTerm*12

           monthlyPayment = round(loanAmount * (monthlyRate*pow((1+monthlyRate), numPayments))/ (pow((1+monthlyRate), numPayments)-1),2)

           totalPayment = round(monthlyPayment*(loanTerm*12),2)

           interestPaid = round(totalPayment - loanAmount,2)

           print("For the loan Amount of $",loanAmount," for ",loanTerm," years with interest rate of ",interestRate," %")

           print("The monthly payment is $",monthlyPayment)

           print("Total amount paid for this loan is $",totalPayment)

           print("Total interest paid for this loan is $",interestPaid)

       else:

           break  

def menuChoice():

   menuchoice = int(input("Select one of the command number above: "))

   if menuchoice == 1:

       simpleInterest()

       return

   elif menuchoice == 2:

       mortagePayment()

       return

   elif menuchoice == 99:

       print("Have a nice day...")

       global flag

       flag = 0

       return

   else:

       print("Error: command not recognised")

       menuChoice()

flag = 1

while flag == 1:

   print("\n------------------------------------------------------")

   print("1\tCalculate Simple Interest\n2\tCalculate Mortage Payment\n99\tQuit the Program")

   print("------------------------------------------------------\n")

   menuChoice()

See more about python at brainly.com/question/18502436

#SPJ1

View image lhmarianateixeira