| | |
Plz help me with HW, Python For Loop
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2008
Posts: 4
Reputation:
Solved Threads: 0
Enter initial capital: 2000
Enter percentage: 6.6
Enter number of years: 4
After Year 1 you’ll have 2132.0 dollars
After Year 2 you’ll have 2272.71 dollars
After Year 3 you’ll have 2422.71 dollars
After Year 4 you’ll have 2582.61 dollars
In 4 years, a total interest of 582.61 dollars is paid
above should be the output
initial_capital = float(raw_input("Enter initial capital: "))
percentage = float(raw_input("Enter percentage: "))
year = float(raw_input("Enter number of years: "))
c = initial_capital
r = percentage
r = r/100.00
year = 0
i = c*r
for i in range(year+1,):
c=c*(1+r)
year=year+1
i=c-initial_capital
print "After year",year,"you'll have",c,"dollars"
print "In",year,"years, a total interest of",i,"dollars is paid"
above is my input, result is only showed year 1, rest of years is not showing up
can anyone help me plz thank you.
Enter percentage: 6.6
Enter number of years: 4
After Year 1 you’ll have 2132.0 dollars
After Year 2 you’ll have 2272.71 dollars
After Year 3 you’ll have 2422.71 dollars
After Year 4 you’ll have 2582.61 dollars
In 4 years, a total interest of 582.61 dollars is paid
above should be the output
initial_capital = float(raw_input("Enter initial capital: "))
percentage = float(raw_input("Enter percentage: "))
year = float(raw_input("Enter number of years: "))
c = initial_capital
r = percentage
r = r/100.00
year = 0
i = c*r
for i in range(year+1,):
c=c*(1+r)
year=year+1
i=c-initial_capital
print "After year",year,"you'll have",c,"dollars"
print "In",year,"years, a total interest of",i,"dollars is paid"
above is my input, result is only showed year 1, rest of years is not showing up
can anyone help me plz thank you.
![]() |
Other Threads in the Python Forum
- Previous Thread: HELP ON WxPython
- Next Thread: Call another program
Views: 1074 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for Python
abrupt apache approximation argv beginner binary book calculator change cipher client code converter countpasswordentry cturtle dictionaries dictionary drive dynamic examples excel file float format ftp function gui hints homework import inches input java keyboard library line linux list lists loop maze mouse mysqldb mysqlquery newb number numbers output parsing path plugin port prime program programming projects py2exe pygame pymailer pyqt python random recursion recursive remote script scrolledtext search session signal singleton socket ssh string strings strip table terminal text textarea thread threading time tkinter tlapse trick tuple tutorial ubuntu unicode unit urllib urllib2 variable verify vigenere windows wordgame wxpython xlwt






