Guest User

Untitled

a guest
Jan 24th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. '''
  2. Name:Brian Lam
  3. Date: Oct 06 2011
  4. Description: This program will calculate the escape velocity, given the input of
  5. circumference of the planet, and acceleration due to gravity.
  6. '''
  7.  
  8. #Declares Global Constants
  9. PI = 3.14159265
  10. GRAVITY_CONSTANT = 6.67428*10**-11
  11.  
  12. #Defines the main function
  13. def main():
  14.     circumference = input ('Circumference (m) of  planet? ')
  15.     acceleration = input ('Acceleration due to gravity (m/s^2)? ')
  16.     escape_velocity(circumference, acceleration)
  17.    
  18. #Defines the function, escape_velocity with parameters
  19. def escape_velocity(circumference, acceleration):
  20.     radius = ((circumference /PI) / 2)
  21.     mass = ((acceleration * (radius**2)) / GRAVITY_CONSTANT)  
  22.     vescape = (((2 * (GRAVITY_CONSTANT * mass)) / radius))**0.5
  23.     display_results (radius, mass, vescape)
  24.  
  25. #Defines the function, display_results
  26. def display_results (radius, mass, vescape):
  27.     print ' '
  28.     print 'Calculating the escape velocity...'
  29.     print 'Planet radius = % .1f km' % (radius/1000)        
  30.     print 'Planet mass = %.1f x 10^21 kg' % (mass/10**21)              
  31.     print 'Escape Velocity = % .1f km/s' % (vescape/1000)
  32.    
  33. main()
Add Comment
Please, Sign In to add comment