#! /usr/bin/env python """ satellite.py is program which calculates the altitude of a circular orbiting satellite for a given orbit period. The program asks the user to input the period T and print out the value for the height (altitude) using the formula h = ((G*M*T**2) / (4 pi**2))**(1/3) - R where G is Newton's constant, M is the mass and R is the raduis of the Earth. derivation of the above equation F == ma GmM/r**2 == w**2 r with w == 2pi f & f == 1/T r**3 == GMT**2/(2pi)**2 with r == R + h h == ( (G*M*T**2)/(4 pi**2) )**(1/3) - R ### PROGRAM OUTPUT ### hpc-login-24 522% satellite.py Enter period in minutes: 90 Altitude is 279 km hpc-login-24 523% satellite.py Enter period in minutes: 45 Altitude is -2182 km ### DISCUSSION ### Altitude is defined as the distance above the Earth's surface (i.e.: radial distance = R_Earth + altitude ). A negative value for altidude implies an impossible orbital radius within the Earth's surface. Note: changing the input line to the code below will check and require the user to input a period which does not produce negative results. h = -1 while h < 0: T = 60 * float(raw_input("Enter period in minutes: ")) # T is the orbital period in units of seconds # Calculate the satellite height h = (G*M*T*T/(4*pi*pi))**(1/3) - R if h < 0: print("Orbital period results in a negative altitude of {0:2.0f} m.".format(h) ) ### Paul Eugenio PHZ4151C Jan 15, 2019 """ # program header code from __future__ import division, print_function from math import pi # main body of program G = 6.67e-11 # Newton's gravitational constant M = 5.97e24 # Mass of the Earth (kg) R = 6371e3 # Radius of the Earth (m) T = 60 * float(raw_input("Enter period in minutes: ")) # T is the orbital period in units of seconds # Calculate the satellite height h = (G*M*T*T/(4*pi*pi))**(1/3) - R print( "Altitude is {0:2.0f} km".format(h/1000) )