relax

Finished
11class SpaceAge:
2 """
3 A class to calculate the age of a person on different planets in our Solar System.
4
5 The age is calculated based on the number of seconds passed since birth,
6 and converted to planetary years according to each planet's orbital period.
7
8 Attributes:
9 seconds (int): The age in seconds.
10 earth_years (float): The age converted to Earth years.
11 """
12
13 # Earth year in seconds
14 EARTH_YEAR_SECONDS = 31557600
15
16 # Orbital periods in Earth years
17 ORBITAL_PERIODS = {
18 'mercury': 0.2408467,
19 'venus': 0.61519726,
20 'earth': 1.0,
21 'mars': 1.8808158,
22 'jupiter': 11.862615,
23 'saturn': 29.447498,
24 'uranus': 84.016846,
25 'neptune': 164.79132
26 }
27
228 def __init__(self, seconds: int) -> None:
3 pass
29 """
30 Initialize the SpaceAge object with the given age in seconds.
31
32 Args:
33 seconds (int): The age in seconds.
34 """
35 self.seconds = seconds
36 self.earth_years = seconds / self.EARTH_YEAR_SECONDS
37
38 def on_mercury(self) -> float:
39 """
40 Calculate the age on Mercury.
41
42 Returns:
43 float: The age on Mercury in years, rounded to 2 decimal places.
44 """
45 # Edge Case: Standard calculation for Mercury
46 return round(self.earth_years / self.ORBITAL_PERIODS['mercury'], 2)
47
48 def on_venus(self) -> float:
49 """
50 Calculate the age on Venus.
51
52 Returns:
53 float: The age on Venus in years, rounded to 2 decimal places.
54 """
55 # Edge Case: Standard calculation for Venus
56 return round(self.earth_years / self.ORBITAL_PERIODS['venus'], 2)
57
58 def on_earth(self) -> float:
59 """
60 Calculate the age on Earth.
61
62 Returns:
63 float: The age on Earth in years, rounded to 2 decimal places.
64 """
65 # Edge Case: Standard calculation for Earth
66 return round(self.earth_years / self.ORBITAL_PERIODS['earth'], 2)
67
68 def on_mars(self) -> float:
69 """
70 Calculate the age on Mars.
71
72 Returns:
73 float: The age on Mars in years, rounded to 2 decimal places.
74 """
75 # Edge Case: Standard calculation for Mars
76 return round(self.earth_years / self.ORBITAL_PERIODS['mars'], 2)
77
78 def on_jupiter(self) -> float:
79 """
80 Calculate the age on Jupiter.
81
82 Returns:
83 float: The age on Jupiter in years, rounded to 2 decimal places.
84 """
85 # Edge Case: Standard calculation for Jupiter
86 return round(self.earth_years / self.ORBITAL_PERIODS['jupiter'], 2)
87
88 def on_saturn(self) -> float:
89 """
90 Calculate the age on Saturn.
91
92 Returns:
93 float: The age on Saturn in years, rounded to 2 decimal places.
94 """
95 # Edge Case: Standard calculation for Saturn
96 return round(self.earth_years / self.ORBITAL_PERIODS['saturn'], 2)
97
98 def on_uranus(self) -> float:
99 """
100 Calculate the age on Uranus.
101
102 Returns:
103 float: The age on Uranus in years, rounded to 2 decimal places.
104 """
105 # Edge Case: Standard calculation for Uranus
106 return round(self.earth_years / self.ORBITAL_PERIODS['uranus'], 2)
107
108 def on_neptune(self) -> float:
109 """
110 Calculate the age on Neptune.
111
112 Returns:
113 float: The age on Neptune in years, rounded to 2 decimal places.
114 """
115 # Edge Case: Standard calculation for Neptune
116 return round(self.earth_years / self.ORBITAL_PERIODS['neptune'], 2)
117
118 # Handled Edge Cases: Standard calculations for all planets with proper rounding to 2 decimal places
Test NameStatus
test_age_on_earth
Pass
test_age_on_jupiter
Pass
test_age_on_mars
Pass
test_age_on_mercury
Pass
test_age_on_neptune
Pass
test_age_on_saturn
Pass
test_age_on_uranus
Pass
test_age_on_venus
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.