Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
iTERATION HELP
#1
Hi all,
 Although I'm newbie in Python I am trying to do an iteration for a calculator than I built in Excel.
Below you can see the function created. Basically, I want to iterate for 30 cycles where cycle one = cycle 0 * number, but cycle 2= cycle one * number where number is a constant. I know it works with the code below but if I want to do 1000 cycles it will force me to write 1000 times the same calculation. I tried to find a solution but I haven't got a clear answer. 
Can you give me hand? I know there must be an easier way because, otherwise programming makes no sense!!!
Cheers 
def OPEX_evolution():

   Total_initial = Total_OPEX
   print(1,Total_initial)

   for n in range(2,3):
       Total_annually_1= Total_initial*(1+Interest_Rate)
       print(n,Total_annually_1)
   for n in range(3,4):
       Total_annually_2=Total_annually_1*(1+Interest_Rate)
       print(n,Total_annually_2)
   for n in range(4,5):
       Total_annually_3=Total_annually_2*(1+Interest_Rate)
       print(n,Total_annually_3)
   for n in range(5,6):
       Total_annually_4=Total_annually_3*(1+Interest_Rate)
       print(n,Total_annually_4)
   for n in range(6,7):
       Total_annually_5=Total_annually_4*(1+Interest_Rate)
       print(n,Total_annually_5)
   for n in range(7,8):
       Total_annually_6=Total_annually_5*(1+Interest_Rate)
       print(n,Total_annually_6)
   for n in range(8,9):
       Total_annually_7=Total_annually_6*(1+Interest_Rate)
       print(n,Total_annually_7)
   for n in range(9,10):
       Total_annually_8=Total_annually_7*(1+Interest_Rate)
       print(n,Total_annually_8)

OPEX_evolution()
Reply


Messages In This Thread
iTERATION HELP - by FGT - Nov-09-2016, 07:30 AM
RE: iTERATION HELP - by wavic - Nov-09-2016, 08:48 AM
RE: iTERATION HELP - by FGT - Nov-09-2016, 11:57 AM
RE: iTERATION HELP - by wavic - Nov-09-2016, 12:20 PM
RE: iTERATION HELP - by Larz60+ - Nov-09-2016, 02:39 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020