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
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()