<jupyter_start><jupyter_text>Snail and wellA snail falls at the bottom of a 125 cm well. Each day the snail rises 30 cm. But at night, while sleeping, slides 20 cm because the walls are wet. How many days does it take to escape from the well?TIP: http://puzzles.nigelcoldwell.co.uk/sixtytwo.htm  Solución<jupyter_code># Assign problem data to variables with representative names
# well height, daily advance, night retreat, accumulated distance
well_height_cm = 125
daily_advance_cm = 30
night_retreat_cm = 20
accumulated_distance_cm = 0

# Assign 0 to the variable that represents the solution
days = 0

# Write the code that solves the problem

# While the total distance traveled is less than the well height continue looping
while (accumulated_distance_cm < well_height_cm):
#(1 day cycle)
  days += 1 # each loop adds a day to the counter (1 day cycle)
  accumulated_distance_cm += daily_advance_cm # add 30cm to total distance travled

  if accumulated_distance_cm > well_height_cm: # if the total distance travled is greater than the well height end the loop
    break # end loop via break
    
  else: # otherwise continue to night cycle
  #(1 night cycle)
    accumulated_distance_cm -= night_retreat_cm

    


# Print the result with print('Days =', days)
print('Days =', days)

# The total days elapsed is 11 because on the 10th night the snail drops to 100cm, 
#the next morning the snail moves 30cm making a total of 130cm which is 5cm over the well height, 
#thus removing the snail from the wells clutches!!!<jupyter_output>Days = 11<jupyter_text>Goals1. Treatment of variables2. Use of loop **while**3. Use of conditional **if-else**4. Print in console  BonusThe distance traveled by the snail is now defined by a list.```advance_cm = [30, 21, 33, 77, 44, 45, 23, 45, 12, 34, 55]```How long does it take to raise the well?What is its maximum displacement in one day? And its minimum?What is its average speed during the day?What is the standard deviation of its displacement during the day?<jupyter_code>import statistics 

# Assign problem data to variables with representative names
# well height, daily advance, night retreat, accumulated distance
advance_cm, well_height_cm, night_retreat_cm, accumulated_distance_cm= [30, 21, 33, 77, 44, 45, 23, 45, 12, 34, 55], 125, 20, 0


# Assign 0 to the variable that represents the solution
days = 0 # Total days elapsed

# Write the code that solves the problem
for comp_day in advance_cm:  # counts each number in array and counts it as a day
#(1 full day)
    days += 1 # add day to counter
    accumulated_distance_cm += comp_day # add current dist travled in day and add to total moved distance
    
    if accumulated_distance_cm > well_height_cm: #if snail is over the well height break for loop
        break # exit loop via break
        
    else: # if not over well height snail = sleep so remove 20cm from total height
    #(1 full night)
        accumulated_distance_cm -= night_retreat_cm # night time draw back



# Print the result with print('Days =', days)
print('Days =', days)

# What is its maximum displacement in a day? And its minimum?
max_disp, mini_disp = max(advance_cm), min(advance_cm) #using python version of what was taught on lesson for google sheets
print("Maximum Displacment = {0} \nMinimum Displacement = {1}".format(max_disp, mini_disp))

# What is its average progress?
avrg_prog = sum(advance_cm)/len(advance_cm) # adding all distances travled and dividing them by the amount of numbers in array
print("Average Progress = {0}".format(avrg_prog))

# What is the standard deviation of your displacement during the day?
print("Standard Deviation = {0}".format(statistics.pstdev(advance_cm))) # Using imported statistics library from python to get the standard deviation.<jupyter_output>Days = 6
Maximum Displacment = 77 
Minimum Displacement = 12
Average Progress = 38.09090909090909
Standard Deviation = 17.159437082600803
StarcoderdataJupyterStructuredCleanDedup