跳到内容
🛠️ToolsShed

Age on Other Planets

根据行星轨道周期计算您在太阳系各行星上的年龄。

关于此工具

其他行星上的年龄计算器根据每颗行星绕太阳一周所需的时间来计算你在太阳系各行星上会有多少岁。由于行星的公转周期不同——水星仅需 88 天完成一周,而海王星需要 165 年——你的年龄会根据你在哪颗行星上而完全不同。这是一种有趣的方式来探索行星运动与相对时间的互动关系。

只需输入你的出生日期,工具会立即显示你在所有八颗行星上的年龄。计算方法是将你在地球上生活的总天数除以每颗行星的公转周期(以天为单位)。你会立刻看到,在水星上你会年长得多(因为轨道周期短,公转次数多),而在海王星上你会年轻得多(因为人类一生期间它几乎完成不了一次公转)。

这个工具对学习太阳系和轨道力学的学生有教育意义,对任何对太空感到好奇的人都很有趣,是很好的谈话开场白。它完全在你的浏览器中运行,所以没有数据被存储或发送到任何地方。

常见问题

代码实现

from datetime import date

ORBITAL_PERIODS = {
    "Mercury": 0.2408467,
    "Venus": 0.6151972,
    "Earth": 1.0,
    "Mars": 1.8808158,
    "Jupiter": 11.862615,
    "Saturn": 29.447498,
    "Uranus": 84.016846,
    "Neptune": 164.79132,
}

def age_on_planets(birth_date: date, ref_date: date | None = None) -> dict:
    if ref_date is None:
        ref_date = date.today()
    earth_years = (ref_date - birth_date).days / 365.25
    return {
        planet: round(earth_years / period, 2)
        for planet, period in ORBITAL_PERIODS.items()
    }

birth = date(1990, 6, 15)
ages = age_on_planets(birth)
for planet, age in ages.items():
    print(f"{planet:8s}: {age:8.2f} years")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.