In: Computer Science
Python Programming
You can calculate a person’s weight on the different planets within our solar system by multiplying their mass by the gravity factor on the surface of the planet.
Weight = Earth Weight x Surface Gravity Factor
Planet |
Surface Gravity Factor |
Mercury |
0.38 |
Venus |
0.91 |
Moon |
0.165 |
Mars |
0.38 |
Jupiter |
2.34 |
Saturn |
0.93 |
Uranus |
0.92 |
Neptune |
1.12 |
Pluto |
0.066 |
\
For example if you weigh 100 pounds on earth on Mars you would be:
Mars Weight 38 = 100 x .38
You Must Code the following:
Put s prefixes in front of variables that contain string values and n prefix for variables that contain numbers.
Please include screenshots. thank you.
/******************************main.py***********************/
#declaring constant
MERCURY = .38
VENUS = .91
MOON = .165
MARS = .38
JUPITER = 2.34
SATURN = .93
URANUS = .92
NEPTUNE = 1.12
PLUTO = 0.066
#input name and Weight on earth
sName = input("Enter Your Name: ")
nWeight = float(input("Enter Weight: "))
#calculate Weight on Each Planet
weightOnMercury = nWeight * MERCURY
weightOnVenus = nWeight * VENUS
weightOnMoon = nWeight * MOON
weightOnMars = nWeight * MARS
weightOnJupiter = nWeight * JUPITER
weightOnSaturn = nWeight * SATURN
weightOnUranus = nWeight * URANUS
weightOnNeptune = nWeight * NEPTUNE
weightOnPluto = nWeight * PLUTO
#print Weight on each Planet
print(sName+"'s Weight on \"Solar System\"")
print("Planet\t\tWeight")
print("MERCURY\t\t%.2f"%weightOnMercury)
print("VENUS\t\t%.2f"%weightOnVenus)
print("MOON\t\t%.2f"%weightOnMoon)
print("MARS\t\t%.2f"%weightOnMars)
print("JUPITER\t\t%.2f"%weightOnJupiter)
print("SATURN\t\t%.2f"%weightOnSaturn)
print("URANUS\t\t%.2f"%weightOnUranus)
print("NEPTUNE\t\t%.2f"%weightOnNeptune)
print("PLUTO\t\t%.2f"%weightOnPluto)
Please let me know if you have any doubt or modify the answer, Thanks:)