import numpy as np
import matplotlib.pyplot as plt
Run to view results
#Use this cell to calculate the velocity of a ball after falling 2 meters
initialHeight = 2 # meters
gravityAccMag = 9.81 #meters/s^2, magnitude of acceleration due to gravity
##### Begin Editing #####
finalVelocity = (2 * gravityAccMag * initialHeight) ** 0.5 # in meters/s. This should be a vector.
##### End Editing #####
velocityMagnitude = np.linalg.norm(finalVelocity) #numpy.linalg.norm takes the magnitude of an array
print('The final velocity of a ball after falling 2 meters has a magnitude of {} meters/second'.format(velocityMagnitude))
Run to view results
#Use this cell to calculate the magnitude of the drag force for a ball that has fallen 2 meters
vel = velocityMagnitude*np.array([1./np.sqrt(3),1./np.sqrt(6),1./np.sqrt(2)]) # meters/s
r = 0.025 # meters
##### Begin Editing #####
A = np.pi * r**2 #m^2
C = 0.5 #unitless
rho = 1.225 #kg/m^3
dragForce = -0.5 * C * A * rho * np.linalg.norm(vel)**2
##### End Editing #####
dragMagnitude = np.linalg.norm(dragForce)
print('The magnitude of the air drag force is {}'.format(dragMagnitude))
Run to view results
#Run this cell without editing
print(np.linalg.norm(vel)*vel)
print(vel*vel)
Run to view results
#Use this cell to calculate the ratio of the magnitude of the drag force to gravity
##### Begin Editing #####
mass_ball_g = 75
g = 9.81
mass_ball_kg = mass_ball_g / 1000
gravityForce = mass_ball_kg * np.array([0, 0, -g])
##### End Editing #####
gravityMagnitude = np.linalg.norm(gravityForce)
ratio = dragMagnitude / gravityMagnitude
print('The ratio of the air drag force to gravity is {}'.format(ratio))
Run to view results