Hello, I'm very new to python but made this as a sort of exercise. It is a loan calculator that takes into account user input.
r = input('What is your interest rate? ') t = input('How many payments will you make? ') la = input('What was the amount of the loan? ') rt = raw_input('Do you make your payments weekly, monthly, quarterly, or annually? ') r = r + .0 r = r / 100 rr = r / 52 x = (1.0 + rr) ** t y = rr / (x - 1.0) isloanweek = (rr + y) * la rr = r / 12 x = (1.0 + rr) ** t y = rr / (x - 1.0) isloanmonth = (rr + y) * la rr = r / 4 x = (1.0 + rr) ** t y = rr / (x - 1.0) isloanquarter = (rr + y) * la rr = r / 1 x = (1.0 + rr) ** t y = rr / (x - 1.0) isloanannual = (rr + y) * la whatloan = True while whatloan: if rt == 'weekly': print isloanweek whatloan = False elif rt == 'monthly': print isloanmonth whatloan = False elif rt == 'quarterly': print isloanquarter whatloan = False elif rt == 'annually': print isloanannual whatloan = False else: rt = raw_input('Sorry that was not an option, please respond with weekly, monthly, quarterly, or annually: ')
I moved this post to its own thread. As you look at the code there are many lines of repetitious code, a sign that a function is due. Can anybody help Mensa180 in a nice way to improve the Python coding style?
Mensa180, thanks for the code contribution!