Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """This program will calculate the force acting on an object on each of the
- eight planets, the Sun, and Pluto, assuming said object is on the surface."""
- "G is a constant multiplier in Newton's Law of Universal Gravitation"
- G = 0.0000000000667
- "List some facts about the planets for which the force is being calculated"
- def planetList():
- print("The celestial body: Average Density | Planetary Mass | Radius")
- print
- print("Sun: 1.49 | 1989000000 | 696000")
- print("Mercury: 5.43 | 330.2 | 2440")
- print("Mars: 3.94 | 641.85 | 3389.5")
- print("Earth: 5.515 | 5973.6 | 6371")
- print("Jupiter: 1.33 | 1898600 | 69111")
- print("Saturn: 0.70 | 568460 | 58232")
- print("Uranus: 1.30 | 86832 | 25362")
- print("Neptune: 1.76 | 102430 | 24622")
- print("Pluto: 2.0 | 13.105 | 1184")
- "Function that takes input and applies it to Newton's Law of Universal Gravitation"
- def forceCalc(objectMass, planetMass, r):
- force = G * (objectMass * planetMass) / (r ** 2)
- return force
- "Get input for the objects mass, and apply it to the function for each celestial body"
- objectMass = input("Please input the mass of the object in kilograms: ")
- sun = forceCalc(objectMass, 1989000000000000000000000000000, 696000000)
- mercury = forceCalc(objectMass, 3302000000000000000000000, 2440000)
- mars = forceCalc(objectMass, 64185000000000000000000000, 3389500)
- earth = forceCalc(objectMass, 5973600000000000000000000, 6371000)
- jupiter = forceCalc(objectMass, 1898600000000000000000000000, 69111000)
- saturn = forceCalc(objectMass, 568460000000000000000000000, 58232000)
- uranus = forceCalc(objectMass, 86832000000000000000000000, 25362000)
- neptune = forceCalc(objectMass, 102430000000000000000000000, 24622000)
- pluto = forceCalc(objectMass, 13105000000000000000000, 1184000)
- "Output that the user sees, extra print ketywords are to make it look prettier"
- print
- print("Mass entered: %s") % (objectMass)
- print
- print("Sun: %s") % (sun)
- print("Mercury: %s") % (mercury)
- print("Mars: %s") % (mars)
- print("Earth: %s") % (earth)
- print("Jupiter: %s") % (jupiter)
- print("Saturn: %s") % (saturn)
- print("Uranus: %s") % (uranus)
- print("Neptune: %s") % (neptune)
- print("Pluto: %s") % (pluto)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement