# Constants
MONTHLY_RATE = 0.051 / 12
def main():
current_price = get_price_input("current")
last_month_price = get_price_input("last month's")
print_summary(current_price, last_month_price)
def get_price_input(name):
"""Get price input from user, convert to int"""
price = int(input(f"Enter {name} price: "))
return price
def print_summary(current_price, last_month_price):
"""Print formatted summary given current and last month's price"""
change = current_price - last_month_price
print(f"This house is ${current_price:,}.")
print(f"The change is ${change:,} since last month.")
print(f"The estimated monthly mortgage is ${estimate_mortgage(current_price):,.0f}.")
def estimate_mortgage(price):
"""Estimate monthly mortgage based on price"""
return price * MONTHLY_RATE
if __name__ == "__main__":
main()