Overall percentage change from successive changes | Python implementation of above approach ; Calculate successive change of 1 st 2 change ; Calculate successive change for rest of the value ; Driver code ; Calling function
def successiveChange ( arr , N ) : NEW_LINE INDENT result = 0 ; NEW_LINE var1 = arr [ 0 ] ; NEW_LINE var2 = arr [ 1 ] ; NEW_LINE result = float ( var1 + var2 + ( float ( var1 * var2 ) / 100 ) ) ; NEW_LINE for i in range ( 2 , N ) : NEW_LINE INDENT result = ( result + arr [ i ] + ( float ( result * arr [ i ] ) / 100 ) ) ; NEW_LINE DEDENT return result ; NEW_LINE DEDENT arr = [ 10 , 20 , 30 , 10 ] ; NEW_LINE N = len ( arr ) ; NEW_LINE result = successiveChange ( arr , N ) ; NEW_LINE print ( " Percentage ▁ change ▁ is ▁ = ▁ % .2f " % ( result ) , " % " ) ; NEW_LINE