let it go

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 provided, converting it to years
6 according to the orbital periods of various planets.
7
8 Attributes:
9 seconds (int): The age in seconds.
10 earth_year_seconds (float): The number of seconds in an 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 # Edge Case: Negative seconds input
21 # If seconds is negative, we treat it as 0 to avoid negative ages.
22 """
23 self.earth_year_seconds = 31557600
24 if seconds < 0:
25 self.seconds = 0
26 else:
27 self.seconds = seconds
28
29 def on_earth(self) -> float:
30 """
31 Calculate the age on Earth.
32
33 Returns:
34 float: The age on Earth in years, rounded to 2 decimal places.
35
36 # Handled Edge Cases: Negative seconds input
37 """
38 return round(self.seconds / self.earth_year_seconds, 2)
39
40 def on_mercury(self) -> float:
41 """
42 Calculate the age on Mercury.
43
44 Returns:
45 float: The age on Mercury in years, rounded to 2 decimal places.
46
47 # Handled Edge Cases: Negative seconds input
48 """
49 return round(self.seconds / (self.earth_year_seconds * 0.2408467), 2)
50
51 def on_venus(self) -> float:
52 """
53 Calculate the age on Venus.
54
55 Returns:
56 float: The age on Venus in years, rounded to 2 decimal places.
57
58 # Handled Edge Cases: Negative seconds input
59 """
60 return round(self.seconds / (self.earth_year_seconds * 0.61519726), 2)
61
62 def on_mars(self) -> float:
63 """
64 Calculate the age on Mars.
65
66 Returns:
67 float: The age on Mars in years, rounded to 2 decimal places.
68
69 # Handled Edge Cases: Negative seconds input
70 """
71 return round(self.seconds / (self.earth_year_seconds * 1.8808158), 2)
72
73 def on_jupiter(self) -> float:
74 """
75 Calculate the age on Jupiter.
76
77 Returns:
78 float: The age on Jupiter in years, rounded to 2 decimal places.
79
80 # Handled Edge Cases: Negative seconds input
81 """
82 return round(self.seconds / (self.earth_year_seconds * 11.862615), 2)
83
84 def on_saturn(self) -> float:
85 """
86 Calculate the age on Saturn.
87
88 Returns:
89 float: The age on Saturn in years, rounded to 2 decimal places.
90
91 # Handled Edge Cases: Negative seconds input
92 """
93 return round(self.seconds / (self.earth_year_seconds * 29.447498), 2)
94
95 def on_uranus(self) -> float:
96 """
97 Calculate the age on Uranus.
98
99 Returns:
100 float: The age on Uranus in years, rounded to 2 decimal places.
101
102 # Handled Edge Cases: Negative seconds input
103 """
104 return round(self.seconds / (self.earth_year_seconds * 84.016846), 2)
105
106 def on_neptune(self) -> float:
107 """
108 Calculate the age on Neptune.
109
110 Returns:
111 float: The age on Neptune in years, rounded to 2 decimal places.
112
113 # Handled Edge Cases: Negative seconds input
114 """
115 return round(self.seconds / (self.earth_year_seconds * 164.79132), 2)
116
117# Handled Edge Cases: Negative seconds input
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.