Time for action – figuring out the rate

Let's take the values from the Time for action – determining the number of periodic payments section and reverse compute the interest rate from the other parameters.

Fill in the numbers from the previous Time for action section:

print("Interest rate", 12 * np.rate(167, -100, 9000, 0))

The interest rate is approximately 10 percent as expected:

Interest rate 0.0999756420664

What just happened?

We used the NumPy rate() function and the values from the Time for action – determining the number of periodic payments section to compute the interest rate of the loan. Ignoring the rounding errors, we got the initial 10 percent we started with.

Get NumPy : Beginner's Guide - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.