-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfor loop. py.py
More file actions
26 lines (15 loc) · 825 Bytes
/
for loop. py.py
File metadata and controls
26 lines (15 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# use while to create a loop to calculated investment
# This program asks user to enter $ amount for priciple and add annual rate.
# To stop the program user needs to entre SENTENIAL flag which is 0
SENTENIAL = 0
years = 1
principle = float(input('What is your principle amount invested?: '))
interestRate = float(input('What is the interest rate year ' + str(years) +' in % :'))
balance=principle
while interestRate !=SENTENIAL:
years+=1
balance += balance*(interestRate *0.01)
interestRate = float(input('What is the interest rate year ' + str(years) +' in % :'))
print ('At the end of', years, 'years your investment will be ${:,.2f}'.format(balance))
averageIncome = (balance -principle)/ (years -1)
print('Your average yearly income is ${:,.2f}'.format(averageIncome))