Answer:
CODE
import time #importing the time module
import math #importing the math module
pi = math.pi #setting the value of pi
u = 70 #initial velocity
g = 9.8 #acceleration due to gravity
time_step = 0.01 #defines the time increment as 0.01 seconds
time_elapsed = 0.0
maxAngle = 0
angle = 1
h = 5.0 #initial height set at 5m
x = 0.0
maxRange = 0.0
for angle in range(1, 91): #loop iterating angles from 1 to 90
ux = u * math.cos((pi / 180) * angle) #horizontal velocity component
uy = u * math.sin((pi / 180) * angle) #vertical velocity component
for i in range(1000): #executing for 1000 iterations
dragx = 0.5 * 1.225 * 1.4 * 0.8 * ux * ux #calculating the horizontal drag
dragy = 0.5 * 1.225 * 1.4 * 0.8 * uy * uy #calculating the vertical drag
drag_ax = dragx / 65.0 #computing drag acceleration in x
drag_ay = dragy / 65.0 #computing drag acceleration in y
accelx = drag_ax #acceleration yielding in the x direction
accely = g + drag_ay #total acceleration in the y direction
vx = ux - accelx * time_step #calculating x-axis velocity at each instant
vy = uy - accely * time_step #calculating y-axis velocity at each instant
h += uy * time_step - 0.5 * accely * time_step * time_step #height of the projectile at any instant
x += ux * time_step - 0.5 * accelx * time_step * time_step #horizontal range of the projectile at any instant
print("Height " + str(h) + " Range " + str(x)) #displaying current position
time.sleep(time_step) #pausing for 0.01 seconds
time_elapsed += time_step #updating time elapsed
ux = vx #assigning final velocities as initial velocities for the next iteration
uy = vy
if h <= 0.0: #when the projectile reaches ground level
if x > maxRange:
maxRange = x #recording maximum angles
maxAngle = angle
h = 5.0 #resetting variables
x = 0.0
u = 70.0
vx = 0.0
vy = 0.0
print("Wait till the next simulation starts.....")
time.sleep(10.0 - time_elapsed) #waiting for 10 seconds
time_elapsed = 0.0
break
print("The optimal angle for Callista is {} degrees which will yield a range of {} metres".format(str(maxAngle), str(maxRange))) #outputting the optimal angle
Explanation: