Jun-24-2018, 04:55 PM
(Jun-23-2018, 01:21 PM)gontajones Wrote: So...
def mortgage(borrowed, repayment, interest, time): print(f"total left after {time} months \n") while (time > 0): borrowed = borrowed * (1 + interest / 12) borrowed = borrowed - repayment time -= 1 print(borrowed) mortgage(200000, 750, .03, 72)It's not necessary to use a for loop.
Why on earth would you eliminate a range count in favor of a while loop?
Each iteration of a range count takes 3 operations, the equivalent in a while loop takes 10 operations, assuming all internal operations are amalgamated as one.
range is implemented completely in c, while and "time -= 1" are interpreted commands and are very slow comparatively.