![]() |
Homework help - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Homework help (/thread-30700.html) |
Homework help - stevemike - Nov-02-2020 Create variables named i and n to store the interest rate rate and the number of monthly payments. These values will remain constant throughout this problem. 2. Create a variable name start and set it equal to 100,000. Create another variable named increment and set it equal to 10,000. 3. Use a loop to perform the tasks below for each of the house prices that we wish to consider. Note that since we are using i to denote the interest rate, you will need to select a different name for the loop counter. • Calculate the new loan amount to be considered, storing the result in a variable. • Calculate the require monthly payment for this loan amount, rounded to 2 decimal places. • Print the result in the format shown below. Match the format exactly, including the inclusion of the period at the end of the sentence. There should be no spaces following the dollar signs. I can not for the life of me figure this out. relooping with increments RE: Homework help - deanhystad - Nov-02-2020 Read up on the for loop. Setting the increment is built in RE: Homework help - jefsummers - Nov-02-2020 Start at the beginning and do each step. Show your work and where you get stuck. RE: Homework help - LinkAiris - Mar-13-2024 (Nov-02-2020, 12:34 AM)stevemike Wrote: Create variables named i and n to store the interest rate rate and the number of monthly payments. These # Step 1: Create variables for interest rate and number of monthly payments i = 0.05 # Example interest rate (5%) n = 30 # Example number of monthly payments (30 years) # Step 2: Create variables for starting loan amount and increment start = 100000 increment = 10000 # Step 3: Use a loop to perform the required tasks for house_price in range(start, start + 6 * increment, increment): # Calculate new loan amount loan_amount = house_price * 0.8 # Assuming an 80% loan-to-value ratio # Calculate monthly payment using the formula for a fixed-rate mortgage monthly_interest_rate = i / 12 monthly_payments = loan_amount * (monthly_interest_rate * (1 + monthly_interest_rate)**(n*12)) / ((1 + monthly_interest_rate)**(n*12) - 1) monthly_payments = round(monthly_payments, 2) # Print the result in the specified format print(f"For a house price of ${house_price:,.2f}, the monthly payment is ${monthly_payments:,.2f}.")This code uses a loop to iterate over different house prices and calculates the corresponding loan amount and monthly payment. The results are then printed in the specified format. Adjust the interest rate (i), number of monthly payments (n), and other parameters as needed for your specific case. |