Exam 1 Python
Thu Feb 23 2023 03:41:44 GMT+0000 (Coordinated Universal Time)
Saved by @Fiexin
#Program is called myHouse Cost of house less than or equal to 400k houseCost = int(100) # Max Cost of House MAX_HOUSE_COST = int(400000) # How many years user wishes to make morgage payments, either 15 or 30 years years = int(1) # Months in a Year for morgage MONTHS_IN_YEAR = int(12) # Part goes toward your mortgage to pay your principal and interest. added on to mortgage (ESCROW) = float(750.00) #All varibales made now While Function # This while statement sets it to where it will run without problems while houseCost <= MAX_HOUSE_COST: houseCost = int(input("Please enter the cost of your house (must be less or equal to 400,000 integer dollars: ")) # This says while the cost is above 400k it will prompt them to answer until its less or equal to 400000 dollars. while houseCost > MAX_HOUSE_COST: houseCost = int(input("Please enter the cost of your house (must be less or equal to 400,000 integer dollars: ")) # If it finally matches the criteria the loop ends else: break if years == 1 : # If the years chosen is not the 2 options ( 15 or 30), it will prompt ths user to asnwer again until the condition is met. while years != 15 or years != 30: years = int(input("Please enter 15 or 30 years for mortgage payments: ")) if years == 15 or years == 30: break #the total amount of months user is paying morgage numOfMonths = years * MONTHS_IN_YEAR # monthly house payment calculation, total cost of house divided by the total amount of months in mortgage (monthlyPay) = ESCROW + (houseCost / numOfMonths) # prints out the total amount of months they are paying, and monthly payment. print("Number of months for mortgage will be ", numOfMonths ," and your monthly pay will be $", format(monthlyPay, ',.2f'), sep='' ) # Variable used to obtain last digit in monthly payment lastNum = houseCost % 10 # Prints the last number in cost of house print("The last number on the cost of the house is:", lastNum) if lastNum == 0: print('Your house is in perfect condition!') #if lastNum is 1 or 2, then print out 'Your trees are growing nicely!'. However, if lastNum is 1 then print this out one time. If lastNum is 2 then print this out two times. Either way, use a for loop to do this. elif lastNum == 1 or lastNum == 2: for x in range(lastNum): print("Your trees are growing nicely!") #if lastNum is 3,4, or 5, then print out 'Water heater needs to be checked!'. Again, the number of times that this message will be printed will depend on the value of lastNum (3,4, or 5). Again, use a for loop to do this. elif lastNum == 3 or lastNum ==4 or lastNum == 5: for x in range(lastNum): print("Water heater needs to be checked!") #if lastNum is 6,7, or 8, then print out 'Your house is almost done settling!'. Again, the number of times that this message will be printed will depend on the value of lastNum (6,7, or 8). Again, use a for loop to do this. elif lastNum == 6 or lastNum ==7 or lastNum == 8: for x in range(lastNum): print("Your house is almost done settling!") #if lastNum is 9, then print out 'Yikes! Your air conditioner just broke!' one time. elif lastNum == 9: print("Yikes! Your air conditioner just broke!") #otherwise, print out 'Illegal number!' else : print("Illegal number!") print() print() print("This amazingly awesome program was written by Nathan Landin :) YAYYY") print("End of the program :(") # The Enddddd
Exam scripting class #1
Myself
Comments