Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # r
- # date
- # Homework 2 - Landlord
- ##FUNCTIONS SHOULD BE SINGLE PURPOSE, NOT GLOBAL VARIABLES##
- ##WHAT IT NEEDS TO DO ITS WORK SHOULD ONLY COME FROM ITS INPUT PARAMETER##
- ##SHOULDNT NEED TO KNOW ANYTHING ELSE FROM THE PROGRAM##
- #step 1) calculate total monthly rent
- import math
- # what is your credit score?
- # x = float;
- # y = float;
- numRenters = int(input("How many renters? "))
- creditScore = int(input("What is the your lowest credit score? "))
- monthlyIncome = int(input("What is your total monthly income? "))
- isFelon = input("Are you a convicted felon? ")
- hasPet = input("Do you have a cat or dog? ")
- lowBaseRent = int(input("What is the one-bedroom rent? "))
- highBaseRent = int(input("What is the two-bedroom rent? "))
- #function to determine renter eligibility
- #function accepts necessary input parameters
- #function correctly applies eligibility rules
- #function returns appropriate value
- def totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent): ## creditScore,hasPet,baseRent are parameters passed INTO the function
- # if they have good credit give a discount
- LBR = lowBaseRent
- HBR = highBaseRent
- if creditScore >= 740:
- LBR = LBR - (lowBaseRent * 0.01)
- HBR = HBR - (highBaseRent * 0.01)
- # if they have a pet add $100
- if hasPet == 'yes':
- LBR += 100
- HBR += 100
- lowrpp = LBR/numRenters
- highrpp = HBR/numRenters
- return LBR,lowrpp,HBR,highrpp ## return statement is an output, what you want out of the function
- ## tell function to end, go back to where it was running
- #print(totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)) ## testinng
- ###function to determine total monthly rent, "isEligible"
- ###accepts necessary input parameters
- ###correctly calculates total monthly rent
- ###returns appropriate value
- ##
- ##
- def downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent):
- LBR,lowrpp,HBR,highrpp = totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)
- LDP = 2 * LBR + 250
- HDP = 2 * HBR + 250
- lpp = LDP/numRenters
- hpp = HDP/numRenters
- return LDP,lpp,HDP,hpp## output firstPayment
- #print(downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent))##test
- ##
- def isEligible(isFelon,creditScore,monthlyIncome,hasPet,lowBaseRent,highBaseRent,numRenters):
- LBR,lowrpp,HBR,highrpp = totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)
- LDP,lpp,HDP,hpp = downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent)
- if isFelon == 'yes':
- return False
- elif creditScore <= 580:
- return False
- elif monthlyIncome<HBR*3:
- return False
- else:
- print("Get out")
- return LBR,lowrpp,HBR,highrpp,LDP,lpp,HDP,hpp
- #a = downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent)
- #b = totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)
- #x = totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)
- #y = downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent)
- #a,b,x,y = totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)
- #q,w,e,r = downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent)
- y1,y2,y3,y4 = downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent)
- x1,x2,x3,x4 = totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)
- print("Your total monthly rent is: ", x2)
- #print("Your total monthly rent is:",(totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)))
- print("Your rent per person is",x2)
- print("Your your total down payment is",y1)
- print("Your amount per person is",y2/numRenters)
- #print("Your total monthly rent is & rent per person is: {}\nYour total down payment & amount per person is: {} \n".format(x,x/2,y))
- #print('the payment per person for low-end is',(downPayment(numRenters,
- # creditScore,hasPet,lowBaseRent,highBaseRent))(totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)))
- #print('the payment per person for low-end is', x, y)
- #print('Your total low monthly rent is: {0}, and the pay per person is: {1} \n'," ")(downPayment(totalMonthlyRent(creditScore,hasPet,lowBaseRent)))
- #print('the payment per person for low-end is','%.2f' %(total_downpayment(monthlyrent_1(creditScore,hasPet,lowBaseRent))/numRenters))
- #print(downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent))##test
- ##baseRent = totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)
- ##print(isEligible(isFelon,creditScore,monthlyIncome,hasPet,lowBaseRent,highBaseRent))
- ##print(downPayment(totalMonthlyRent(creditScore,hasPet,baseRent,highBaseRent)))
- ###if isFelon == 'yes' or creditScore <= 580 or lowBaseRent >= monthlyIncome/3:
- ### print("Sorry, you aren't eligible")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement