Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hailstones are balls or irregular lumps of ice. They start in a cloud as raindro

ID: 3721330 • Letter: H

Question

Hailstones are balls or irregular lumps of ice. They start in a cloud as raindrops and they are pushed higher and lower in the atmosphere until they freeze many times over and eventually fall on Earth. This problem simulates the sequence of altitude values of a hailstone as it goes through its formation process. . Pick a positive integer value for the initial altitude as the start. 2. If the value of initial altitude is even, divide it by 2 (or halve it) 3. If the value of initial_altitude is odd, multiply it by 3 and add 1 4 Continue this process until the value of initial altitude is 1 (we will consider the altitude of the hailstone right before it drops on Earth to be 1). The variable initial altitude will go through a sequence of values. It will increase and decrease, it will go higher and lower in the atmosphere, but will eventually end at 1 Write a function called hailStoneTracker that takes a single argument initial altitude. The function should print the maximum value(as float) out of all the values initial value went through and return a list of all the values(as float type) that initial altitude went through Here are some examples of calling the function: list hailstoneTracker(5) print("list:", list) Output: Max: 16 list: [5, 16, 8, 4, 2, 1]

Explanation / Answer

def hailStoneTracker(initial_altitude):
final_list=[initial_altitude,]
while not initial_altitude==1:
if(initial_altitude%2==0):
initial_altitude/=2
final_list.append(initial_altitude)
else:
initial_altitude=initial_altitude*3+1
final_list.append(initial_altitude)

return final_list
list=hailStoneTracker(6)
print(list)