Skip to content

Instantly share code, notes, and snippets.

@juanpabloaj juanpabloaj/
Last active Dec 26, 2017

What would you like to do?
Solar System distances from Earth in light-minute
# -*- coding: utf-8 -*-
light_speed = 299792
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__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.