Advertisement
LordWillO

Object on Different Celestial Bodies Force of Gravity Calc

Jul 29th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.22 KB | None | 0 0
  1. """This program will calculate the force acting on an object on each of the
  2. eight planets, the Sun, and Pluto, assuming said object is on the surface."""
  3. "G is a constant multiplier in Newton's Law of Universal Gravitation"
  4. G = 0.0000000000667
  5. "List some facts about the planets for which the force is being calculated"
  6. def planetList():
  7.     print("The celestial body: Average Density | Planetary Mass | Radius")
  8.     print
  9.     print("Sun: 1.49 | 1989000000 | 696000")
  10.     print("Mercury: 5.43 | 330.2      | 2440")
  11.     print("Mars: 3.94    | 641.85     | 3389.5")
  12.     print("Earth: 5.515  | 5973.6     | 6371")
  13.     print("Jupiter: 1.33 | 1898600    | 69111")
  14.     print("Saturn: 0.70  | 568460     | 58232")
  15.     print("Uranus: 1.30  | 86832      | 25362")
  16.     print("Neptune: 1.76 | 102430     | 24622")
  17.     print("Pluto: 2.0    | 13.105     | 1184")
  18. "Function that takes input and applies it to Newton's Law of Universal Gravitation"
  19. def forceCalc(objectMass, planetMass, r):
  20.     force = G * (objectMass * planetMass) / (r ** 2)
  21.     return force
  22. "Get input for the objects mass, and apply it to the function for each celestial body"
  23. objectMass = input("Please input the mass of the object in kilograms: ")
  24. sun = forceCalc(objectMass, 1989000000000000000000000000000, 696000000)
  25. mercury = forceCalc(objectMass, 3302000000000000000000000, 2440000)
  26. mars = forceCalc(objectMass, 64185000000000000000000000, 3389500)
  27. earth = forceCalc(objectMass, 5973600000000000000000000, 6371000)
  28. jupiter = forceCalc(objectMass, 1898600000000000000000000000, 69111000)
  29. saturn = forceCalc(objectMass, 568460000000000000000000000, 58232000)
  30. uranus = forceCalc(objectMass, 86832000000000000000000000, 25362000)
  31. neptune = forceCalc(objectMass, 102430000000000000000000000, 24622000)
  32. pluto = forceCalc(objectMass, 13105000000000000000000, 1184000)
  33. "Output that the user sees, extra print ketywords are to make it look prettier"
  34. print
  35. print("Mass entered: %s") % (objectMass)
  36. print
  37. print("Sun: %s") % (sun)
  38. print("Mercury: %s") % (mercury)
  39. print("Mars: %s") % (mars)
  40. print("Earth: %s") % (earth)
  41. print("Jupiter: %s") % (jupiter)
  42. print("Saturn: %s") % (saturn)
  43. print("Uranus: %s") % (uranus)
  44. print("Neptune: %s") % (neptune)
  45. print("Pluto: %s") % (pluto)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement