0

I need help with question 3 found in the link below http://courses.cse.tamu.edu/davidkebo/csce-110/labs/lab_2.pdf

p = 15000
r = float(input("Enter interest rate (in percentage): "))
n = float(input("Enter loan period (in years): "))
c = p(1+r/100)**n
print()
print(f" At {r}% interest, you need to pay ${c} after {n} years")

I don't know why it's telling me that i have an uncallable 'int' or how i'd get the payoff to be rounded to 2 decimal points

Darren
  • 11
  • I see two questions here, the first might possibly be found here https://stackoverflow.com/questions/9767391/typeerror-int-object-is-not-callable/9767422 the second could be found here https://stackoverflow.com/questions/20457038/how-to-round-to-2-decimals-with-python – tisaconundrum Sep 19 '19 at 23:55

2 Answers2

0

This is because of c = p(1+r/100)**n

Anything with parentheses after it will be regarded as a function call in Python (p(...) in your case). You have to explicity give it a multiplication operator. Because p is an integer equal to 15000, you are trying to call an int... hence the error.

Change it to:
c = p * (1 + r / 100) ** n

Kevin Welch
  • 1,488
  • 1
  • 9
  • 18
  • 1
    I appreciate the help! I now realize that i was looking too much into the code and trying to find a huge flaw . – Darren Sep 19 '19 at 23:46
  • 1
    @Darren Consider accepting this as an answer by clicking the check mark next to it if it helped. – Selcuk Sep 20 '19 at 02:02
0

In most programming languages you must explicitly put the multiplication operator when you want to do multiplication: p*(1+r/100)**n.

c = p * (1+r/100)**n
Selcuk
  • 57,004
  • 12
  • 102
  • 110