Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Name:Brian Lam
- Date: Oct 06 2011
- Description: This program will calculate the escape velocity, given the input of
- circumference of the planet, and acceleration due to gravity.
- '''
- #Declares Global Constants
- PI = 3.14159265
- GRAVITY_CONSTANT = 6.67428*10**-11
- #Defines the main function
- def main():
- circumference = input ('Circumference (m) of planet? ')
- acceleration = input ('Acceleration due to gravity (m/s^2)? ')
- escape_velocity(circumference, acceleration)
- #Defines the function, escape_velocity with parameters
- def escape_velocity(circumference, acceleration):
- radius = ((circumference /PI) / 2)
- mass = ((acceleration * (radius**2)) / GRAVITY_CONSTANT)
- vescape = (((2 * (GRAVITY_CONSTANT * mass)) / radius))**0.5
- display_results (radius, mass, vescape)
- #Defines the function, display_results
- def display_results (radius, mass, vescape):
- print ' '
- print 'Calculating the escape velocity...'
- print 'Planet radius = % .1f km' % (radius/1000)
- print 'Planet mass = %.1f x 10^21 kg' % (mass/10**21)
- print 'Escape Velocity = % .1f km/s' % (vescape/1000)
- main()
Add Comment
Please, Sign In to add comment