A.2.1

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 into years for each planet considering their orbital periods.
7
8 Attributes:
9 seconds (int): The age in seconds.
10 earth_year_in_seconds (float): Number of seconds in one Earth year (31,557,600).
11 """
12
213 def __init__(self, seconds: int) -> None:
3 pass
14 """
15 Initialize the SpaceAge class with the given number of seconds.
16
17 Args:
18 seconds (int): The age in seconds.
19
20 # Handled Edge Cases: None for initialization
21 """
22 self.seconds = seconds
23 self.earth_year_in_seconds = 31557600 # 365.25 * 24 * 60 * 60
24
25 def on_earth(self) -> float:
26 """
27 Calculate the age on Earth.
28
29 Returns:
30 float: The age on Earth in years, rounded to 2 decimal places.
31
32 # Handled Edge Cases: None (direct calculation)
33 """
34 return round(self.seconds / self.earth_year_in_seconds, 2)
35
36 def on_mercury(self) -> float:
37 """
38 Calculate the age on Mercury.
39
40 Returns:
41 float: The age on Mercury in years, rounded to 2 decimal places.
42
43 # Handled Edge Cases: None (direct calculation)
44 """
45 return round(self.on_earth() / 0.2408467, 2)
46
47 def on_venus(self) -> float:
48 """
49 Calculate the age on Venus.
50
51 Returns:
52 float: The age on Venus in years, rounded to 2 decimal places.
53
54 # Handled Edge Cases: None (direct calculation)
55 """
56 return round(self.on_earth() / 0.61519726, 2)
57
58 def on_mars(self) -> float:
59 """
60 Calculate the age on Mars.
61
62 Returns:
63 float: The age on Mars in years, rounded to 2 decimal places.
64
65 # Handled Edge Cases: None (direct calculation)
66 """
67 return round(self.on_earth() / 1.8808158, 2)
68
69 def on_jupiter(self) -> float:
70 """
71 Calculate the age on Jupiter.
72
73 Returns:
74 float: The age on Jupiter in years, rounded to 2 decimal places.
75
76 # Handled Edge Cases: None (direct calculation)
77 """
78 return round(self.on_earth() / 11.862615, 2)
79
80 def on_saturn(self) -> float:
81 """
82 Calculate the age on Saturn.
83
84 Returns:
85 float: The age on Saturn in years, rounded to 2 decimal places.
86
87 # Handled Edge Cases: None (direct calculation)
88 """
89 return round(self.on_earth() / 29.447498, 2)
90
91 def on_uranus(self) -> float:
92 """
93 Calculate the age on Uranus.
94
95 Returns:
96 float: The age on Uranus in years, rounded to 2 decimal places.
97
98 # Handled Edge Cases: None (direct calculation)
99 """
100 return round(self.on_earth() / 84.016846, 2)
101
102 def on_neptune(self) -> float:
103 """
104 Calculate the age on Neptune.
105
106 Returns:
107 float: The age on Neptune in years, rounded to 2 decimal places.
108
109 # Handled Edge Cases: None (direct calculation)
110 """
111 return round(self.on_earth() / 164.79132, 2)
Test NameStatus
test_age_on_venus
Fail
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

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