''' Purpose: deepen variable manipulation understanding ''' # first generation generation = 1 nbr_rabbits = 2 print( 'Generation: ', generation ) print( 'Rabbits: ', nbr_rabbits ) input() # next generation generation = generation + 1 # Evaluate the right hand side so look into the generation # box, get that value, and update the generation box (value of variable) by adding 1 to the # value previously in that generation box # This is called reassignment. When you take a variable already assigned a value, # and say that that variable is now equal to a new value (updating that value) nbr_rabbits = 2 * nbr_rabbits print( 'Generation: ', generation ) print( 'Rabbits: ', nbr_rabbits ) input() # next generation generation = generation + 1 nbr_rabbits = 2 * nbr_rabbits print( 'Generation: ', generation ) print( 'Rabbits: ', nbr_rabbits ) input() # next generation generation = generation + 1 # So why doesn't it get that generation value we # had previously? Because it was updated! So it takes the most recently # updated value of generation and updates that accordingly # so we went from 2 rabbits and said multiply that by 2 # now nbr_rabbits is 4 rabbits and nbr_rabbits = 2 * nbr_rabbits print( 'Generation: ', generation ) print( 'Rabbits: ', nbr_rabbits ) input() # next generation generation = generation + 1 nbr_rabbits = 2 * nbr_rabbits print( 'Generation: ', generation ) print( 'Rabbits: ', nbr_rabbits ) input()