Instantly share code, notes, and snippets.

Embed
What would you like to do?
Solar System distances from Earth in light-minute
#!/usr/bin/python
# -*- coding: utf-8 -*-
# https://image.gsfc.nasa.gov/poetry/venus/q89.html
light_speed = 299792
# https://theplanets.org/distances-between-planets/
distances_from_earth = [
{'name': 'Sun', 'distance': 150000000},
{'name': 'Mercury', 'distance': 91691000},
{'name': 'Venus', 'distance': 41400000},
{'name': 'Moon', 'distance': 384402},
{'name': 'Mars', 'distance': 78340000},
{'name': 'Asteroid Belt', 'distance': 4.787e+8},
{'name': 'Jupiter', 'distance': 628730000},
{'name': 'Saturn', 'distance': 1275000000},
{'name': 'Uranus', 'distance': 2723950000},
{'name': 'Neptune', 'distance': 4351400000},
{'name': 'Kuiper Belt', 'distance': 7.33e+9},
{'name': 'Oort Cloud', 'distance': 7.47989e+12},
]
def to_minutes(distance):
return float(distance) / (light_speed * 60)
def main():
for item in distances_from_earth:
print item['name'], round(to_minutes(item['distance']), 2)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment