Question: # Constants for default values and messages WELCOME _ TEXT = Welcome to the Mortgage Calculator! MAIN _ PROMPT = Do you wish to

# Constants for default values and messages
WELCOME_TEXT = "Welcome to the Mortgage Calculator!"
MAIN_PROMPT ="Do you wish to process a new mortgage? (Y/N): "
LOCATION_NOT_KNOWN_TEXT = "Location not recognized. Using national averages."
# Property tax rates and real estate prices per square foot by location
location_data ={
"Seattle": {"tax_rate": 0.01, "price_per_sqft": 500},
"San Francisco": {"tax_rate": 0.012, "price_per_sqft": 800},
"Austin": {"tax_rate": 0.008, "price_per_sqft": 300},
"East Lansing": {"tax_rate": 0.011, "price_per_sqft": 250}
}
# National averages
AVERAGE_NATIONAL_PROPERTY_TAX_RATE =0.01
AVERAGE_NATIONAL_PRICE_PER_SQ_FOOT =200
APR_2023=3.5 # Default APR value if not provided
def get_user_input(prompt, data_type=float, default='NA'):
"""Get user input and convert to specified data type, or return default."""
user_input = input(prompt)
if user_input.upper()=='NA':
return default
return data_type(user_input)
def main():
print(WELCOME_TEXT)
while True:
if input(MAIN_PROMPT).upper()!='Y':
print("Thank you for using the Mortgage Calculator.")
break
# User inputs
location = input("Enter the desired location of the house: ")
square_footage = get_user_input("Enter the desired square footage: ", default='NA')
max_monthly_payment = get_user_input("Enter the desired maximum monthly payment: ", default='NA')
down_payment = get_user_input("Enter the expected down payment: ", default=0.0)
apr = get_user_input("Enter the current APR: ", default=APR_2023)/100 # Convert percentage to fraction
# Handle location
if location in location_data:
tax_rate = location_data[location]['tax_rate']
price_per_sqft = location_data[location]['price_per_sqft']
else:
print(LOCATION_NOT_KNOWN_TEXT)
tax_rate = AVERAGE_NATIONAL_PROPERTY_TAX_RATE
price_per_sqft = AVERAGE_NATIONAL_PRICE_PER_SQ_FOOT
# Calculations and output logic based on provided inputs
# This is where you'd implement the logic for the different cases
# For example, for case 1(square footage only):
if square_footage !='NA' and max_monthly_payment =='NA':
# Implement calculation logic here
pass
# Similarly, handle other cases...
if __name__=="__main__":
main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!