142k views
3 votes
Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two inputs, current price and last month's price (both integers). Then, output a summary listing the price, the change since last month, and the estimated monthly mortgage computed as (current_price *

0. 051

) / 12. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print (f'\{your_value:. 2f

}

') Ex: If the input is:

200000

210000



the output is: This house is

$200000
. The change is

$−10000

since last month. The estimated monthly mortgage is

$850. 00
. Note: Getting the precise spacing, punctuation, and newlines exactly right is a key point of this assignment. Such precision is an important part of programming.

452444. 3279450. Q×32qy7

\begin{tabular}l LAB \\ ACTIVITY & 3. 15. 1: LAB: Input and formatted output: House real estate summary \end{tabular}

0/10

main. Py Load default template. 1 current_price

=int(input())

2 last_months_price

=int(input())

1 Answer

3 votes

Answer:

Step-by-step explanation:

Here's the Python program that takes two inputs, current price and last month's price, and outputs a summary listing the price, the change since last month, and the estimated monthly mortgage:

current_price = int(input())

last_months_price = int(input())

price_diff = current_price - last_months_price

mortgage_estimate = (current_price * 0.051) / 12

print(f'This house is ${current_price}.')

print(f'The change is ${price_diff}.')

print(f'The estimated monthly mortgage is ${mortgage_estimate:.2f}.')

The program starts by reading the current price and last month's price from the user using the input() function and converting them to integers using the int() function. Then, it calculates the difference between the current price and last month's price and stores it in the price_diff variable.

Next, it calculates the estimated monthly mortgage using the formula given in the problem statement and stores it in the mortgage_estimate variable.

Finally, it prints out the summary using the print() function and formatted strings (f-strings) that display the values of the variables with two digits after the decimal point. Note that the \\ character is not necessary because the print() function automatically adds a newline character at the end of each line.

Sample output for current price=200000 and last month's price=210000:

This house is $200000.

The change is $-10000.

The estimated monthly mortgage is $850.00.

User DuckPyjamas
by
8.2k points