#!/usr/bin/env python import os,sys from pprint import pprint from math import sin, pi import random # ## Instructions (for reference): # 1. Initialize the height of the particle to 100 meters. h = 100 # 2. Use a while loop to simulate the motion of the particle until it hits the ground. # 3. Inside the while loop, use an if-else statement to check if the particle has hit the ground. # 4. Update the height of the particle using the equation of motion: h = hinitial − 1/2 * g * (t)2. # 5. Print the height of the particle at each time step. # 6. Use a for loop to iterate through the time steps. # h = h - 1/2 * g * t^2 # 1. Initialize the height from which the particle is released. t_step = float(input("Enter the time step in seconds: ")) h_current = float(input("Enter the height in meters: ")) h_initial = h_current t_current = 0 while (h_current >= 0): # 4. Print the height of the particle at each time step until it hits the ground. print(f'Time: {t_current:.1f} s, Height: {h_current:.2f} m') # 2. Use a loop to update the position of the particle at each time step. t_current += t_step h_current = h_initial - (1/2 * 9.8 * (t_current**2)) # 3. Use an if-else statement to check if the particle has hit the ground. if (h_current < 0): print(f'Time: {(t_current):.1f} s, Height: {0:.2f} m') print(f'has hit the ground') break