I'm sorry for the rudimentary question about Python's For statement,
The following formula does not show why the compounding of the principals (Savings) is calculated.
savings = 100 for i in range (15): savings + = savings * 0.05 print (savings)
This result is about 207.9 (15-year compound interest calculation with a principal of 100 and an interest rate of 5%).
If savings + = savings * 0.05, then 100 + 100 * 0.05 would be 105, and that would be repeated 15 times.
Answer # 1
saing changes in the loop.
Try executing the print statement.
savings = 100 for i in range (15): print (savings) savings + = savings * 0.05 print (savings)
Answer # 2
15% interest rate of 15% Since the annual compounding calculation,
savings + = savings * 0.05can be rewritten as
savings * = 1.05. You will see whether savings * 0.05is fine.
As Katoy mentioned,
savingsis avariablethat changes with each loop.
savings = 100 for i in range (15): savings * = 1.05 print (savings) print (savings)
Answer # 3
savings + = savings * 0.05 is
Savings = savings + savings * 0.05
If you transform the formula
You can also write savings = savings * 1.05
If this is the case
It is the definition of compound interest calculation itself.
savings = 100 for i in range (15): print (savings) # try to write output savings = savings * 1.05 print (savings)
The results are printed below.
- about repeated operations in python for statement
- python - about importing intertools
- python - about the list when calling a function in another file
- [python] about aoj-0105 book index
- python - about the error "allocation of 536870912 exceeds 10% of system memory" when learning cnn
- [python] about atcoder arc006b
- python - about a problem of satcoder agc39
- python - about keras maxpooling2d
- python - [django] about access from another terminal in lan
- python - about tkinter line creation (?)
- python: about list arguments
- about installing python
- tell me about python iteration statements
- [python3] i want to use if statement in integration using sympy
- about installing python-twitter ・i would like to know the difference between tweepy and python-twitter
- about line break display in python
- about python flask
- about list behavior in python
- about installing python on mac
- about python timeout
- python - how to remove a list from a tuple and store only the value
- python - with pycharm, processing does not proceed without error
- python - regarding the problem that tries to decompose a string apostrophe using a dictionary but fails
- python - common behavior for everything in django
- python - i want to split one array into two without duplication
- about the problem that float subtraction does not work in numerical calculation in python
- python - something went wrong in the jupiter lab
- python - i cannot put multiple data scraped by selenium in django into a list and display it
- python - how to deal with error when converting pandas datetime type
- i want to read python time series data while shifting by 1 day