Advertisement
Guest User

andypython

a guest
Jan 20th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.70 KB | None | 0 0
  1. # r
  2. # date
  3. # Homework 2 - Landlord
  4.  
  5. ##FUNCTIONS SHOULD BE SINGLE PURPOSE, NOT GLOBAL VARIABLES##
  6. ##WHAT IT NEEDS TO DO ITS WORK SHOULD ONLY COME FROM ITS INPUT PARAMETER##
  7. ##SHOULDNT NEED TO KNOW ANYTHING ELSE FROM THE PROGRAM##
  8.  
  9. #step 1) calculate total monthly rent
  10.  
  11. import math
  12.  
  13. # what is your credit score?
  14. # x = float;
  15. # y = float;
  16. numRenters = int(input("How many renters? "))
  17. creditScore = int(input("What is the your lowest credit score? "))
  18. monthlyIncome = int(input("What is your total monthly income? "))
  19. isFelon = input("Are you a convicted felon? ")
  20. hasPet = input("Do you have a cat or dog? ")
  21. lowBaseRent = int(input("What is the one-bedroom rent? "))
  22. highBaseRent = int(input("What is the two-bedroom rent? "))
  23.  
  24. #function to determine renter eligibility
  25. #function accepts necessary input parameters
  26. #function correctly applies eligibility rules
  27. #function returns appropriate value
  28.  
  29. def totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent): ## creditScore,hasPet,baseRent are parameters passed INTO the function
  30. # if they have good credit give a discount
  31. LBR = lowBaseRent
  32. HBR = highBaseRent
  33. if creditScore >= 740:
  34. LBR = LBR - (lowBaseRent * 0.01)
  35. HBR = HBR - (highBaseRent * 0.01)
  36. # if they have a pet add $100
  37. if hasPet == 'yes':
  38. LBR += 100
  39. HBR += 100
  40. lowrpp = LBR/numRenters
  41. highrpp = HBR/numRenters
  42. return LBR,lowrpp,HBR,highrpp ## return statement is an output, what you want out of the function
  43. ## tell function to end, go back to where it was running
  44. #print(totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)) ## testinng
  45.  
  46. ###function to determine total monthly rent, "isEligible"
  47. ###accepts necessary input parameters
  48. ###correctly calculates total monthly rent
  49. ###returns appropriate value
  50. ##
  51.  
  52. ##
  53. def downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent):
  54. LBR,lowrpp,HBR,highrpp = totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)
  55. LDP = 2 * LBR + 250
  56. HDP = 2 * HBR + 250
  57. lpp = LDP/numRenters
  58. hpp = HDP/numRenters
  59. return LDP,lpp,HDP,hpp## output firstPayment
  60. #print(downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent))##test
  61. ##
  62. def isEligible(isFelon,creditScore,monthlyIncome,hasPet,lowBaseRent,highBaseRent,numRenters):
  63. LBR,lowrpp,HBR,highrpp = totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)
  64. LDP,lpp,HDP,hpp = downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent)
  65. if isFelon == 'yes':
  66. return False
  67. elif creditScore <= 580:
  68. return False
  69. elif monthlyIncome<HBR*3:
  70. return False
  71. else:
  72. print("Get out")
  73. return LBR,lowrpp,HBR,highrpp,LDP,lpp,HDP,hpp
  74.  
  75. #a = downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent)
  76. #b = totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)
  77. #x = totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)
  78. #y = downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent)
  79.  
  80. #a,b,x,y = totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)
  81. #q,w,e,r = downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent)
  82.  
  83. y1,y2,y3,y4 = downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent)
  84. x1,x2,x3,x4 = totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)
  85.  
  86. print("Your total monthly rent is: ", x2)
  87. #print("Your total monthly rent is:",(totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)))
  88. print("Your rent per person is",x2)
  89. print("Your your total down payment is",y1)
  90. print("Your amount per person is",y2/numRenters)
  91.  
  92. #print("Your total monthly rent is & rent per person is: {}\nYour total down payment & amount per person is: {} \n".format(x,x/2,y))
  93.  
  94. #print('the payment per person for low-end is',(downPayment(numRenters,
  95. # creditScore,hasPet,lowBaseRent,highBaseRent))(totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)))
  96. #print('the payment per person for low-end is', x, y)
  97.  
  98.  
  99. #print('Your total low monthly rent is: {0}, and the pay per person is: {1} \n'," ")(downPayment(totalMonthlyRent(creditScore,hasPet,lowBaseRent)))
  100. #print('the payment per person for low-end is','%.2f' %(total_downpayment(monthlyrent_1(creditScore,hasPet,lowBaseRent))/numRenters))
  101.  
  102. #print(downPayment(numRenters,creditScore,hasPet,lowBaseRent,highBaseRent))##test
  103. ##baseRent = totalMonthlyRent(creditScore,hasPet,lowBaseRent,highBaseRent)
  104. ##print(isEligible(isFelon,creditScore,monthlyIncome,hasPet,lowBaseRent,highBaseRent))
  105. ##print(downPayment(totalMonthlyRent(creditScore,hasPet,baseRent,highBaseRent)))
  106.  
  107. ###if isFelon == 'yes' or creditScore <= 580 or lowBaseRent >= monthlyIncome/3:
  108. ### print("Sorry, you aren't eligible")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement