-1

The question is below but how is it calculated in Py and what command should I be entering in Py? Suppose you have $100, which you can invest with a 10% return each year. After one year, it's 100×1.1=110 dollars, and after two years it's 100×1.1×1.1=121. how much money you end up with after 7 years.

Please help.

Thanks to all who answer.

Rahul John
  • 11
  • 2

2 Answers2

1

In Python, the precedence of the ** operator is more than the * operator. Hence your your statement becomes 100 * (1.1 ** 7) and the answer is 194.87171000000012.

You can refer to https://www.tutorialspoint.com/python/operators_precedence_example.htm for more information on operator precedence in Python.

Soumik Rakshit
  • 859
  • 9
  • 22
0

You can also do this, but the other answer is better code:

i = 0
sum = 100
while i < 7:
   sum = sum * 1.1
   i += i
Doortjuh
  • 71
  • 8