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
WELCOMETEXT "Welcome to the Mortgage Calculator!"
MAINPROMPT Do you wish to process a new mortgage? YN:
LOCATIONNOTKNOWNTEXT "Location not recognized. Using national averages."
# Property tax rates and real estate prices per square foot by location
locationdata
"Seattle": taxrate": "pricepersqft:
"San Francisco": taxrate": "pricepersqft:
"Austin": taxrate": "pricepersqft:
"East Lansing": taxrate": "pricepersqft:
# National averages
AVERAGENATIONALPROPERTYTAXRATE
AVERAGENATIONALPRICEPERSQFOOT
APR # Default APR value if not provided
def getuserinputprompt datatypefloat, defaultNA:
Get user input and convert to specified data type, or return default."""
userinput inputprompt
if userinput.upperNA:
return default
return datatypeuserinput
def main:
printWELCOMETEXT
while True:
if inputMAINPROMPTupperY:
printThank you for using the Mortgage Calculator."
break
# User inputs
location inputEnter the desired location of the house:
squarefootage getuserinputEnter the desired square footage: defaultNA
maxmonthlypayment getuserinputEnter the desired maximum monthly payment: defaultNA
downpayment getuserinputEnter the expected down payment: default
apr getuserinputEnter the current APR: defaultAPR # Convert percentage to fraction
# Handle location
if location in locationdata:
taxrate locationdatalocationtaxrate'
pricepersqft locationdatalocationpricepersqft
else:
printLOCATIONNOTKNOWNTEXT
taxrate AVERAGENATIONALPROPERTYTAXRATE
pricepersqft AVERAGENATIONALPRICEPERSQFOOT
# Calculations and output logic based on provided inputs
# This is where you'd implement the logic for the different cases
# For example, for case square footage only:
if squarefootage NA and maxmonthlypayment NA:
# Implement calculation logic here
pass
# Similarly, handle other cases...
if namemain:
main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
