<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 = 125
daily_advance = 30
night_retreat = 20
accumulated_distance = 0


# Assign 0 to the variable that represents the solution

days = 0

# Write the code that solves the problem

while accumulated_distance <= well_height:
    accumulated_distance += daily_advance
    days += 1
    if accumulated_distance >= well_height:
        break
    else:
        accumulated_distance -= night_retreat
    

# Print the result with print('Days =', days)
print ('Days =', days)<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># Assign problem data to variables with representative names
# well height, daily advance, night retreat, accumulated distance

advance_cm = [30, 21, 33, 77, 44, 45, 23, 45, 12, 34, 55]
well_height = 125
accumulated_distance = 0
days = 0
displacement = []


# Assign 0 to the variable that represents the solution



# Write the code that solves the problem

for x in advance_cm:
    daily_advance = x
    
    if accumulated_distance <= well_height:
        accumulated_distance += daily_advance
        displacement.append(daily_advance)
        days +=1
    else:
        break
          
    


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

print('Days =', days)


# What is its maximum displacement in a day? And its minimum?
#whole advancelist
x1 = max(advance_cm)
y1 = min(advance_cm)
print ('Maximum displacement is',x1, 'cm')
print ('Minimum displacement is',y1 , 'cm')

#only days in well

x2 = max(displacement)
y2 = min(displacement)
print ('Maximum displacement is',x2, 'cm')
print ('Minimum displacement is',y2 , 'cm')

# What is its average progress?
# full list
v1 = sum(advance_cm)/len(advance_cm)

print ('Average progress is',v1, 'cm')

#only days in well

v2 = sum(displacement)/len(displacement)

print ('Average progress is',v2, 'cm')



# What is the standard deviation of your displacement during the day?

import math
l1 =[]
l2 =[]

# whole list

for x in advance_cm:
    y = x**2
    l1.append(y)
    
sd = math.sqrt(sum(l1)/len(l1))
print (sd)

# only days in well

for x in displacement:
    y = x**2
    l2.append(y)
    
sd = math.sqrt(sum(l2)/len(l2))
print (sd)<jupyter_output>Days = 4
Maximum displacement is 77 cm
Minimum displacement is 12 cm
Maximum displacement is 77 cm
Minimum displacement is 21 cm
Average progress is 38.09090909090909 cm
Average progress is 40.25 cm
41.777549429850914
45.713783479383984
{'fraction_non_alphanumeric': 0.08873929008567931, 'fraction_numerical': 0.04895960832313342, 'mean_word_length': 4.006125574272588, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '417638', 'license': 'Unlicense', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1013, 'n_words': 405, 'path': 'snail-and-well/snail-and-well.ipynb', 'repo_name': 'menke2013/par-apr-2019-prework', 'size': '3268'}