擅长:python、mysql、java
<h2>调用星团中危险的行星的函数</h2>
<pre><code>class Planet:
def __init__ (self, a_str1, a_str2, a_float):
self.name = a_str1
self.type = a_str2
self.orbital_period = a_float
class Star:
def __init__ (self, a_float, a_planet_list):
self.total_mass = a_float # in solar masses
self.orbiting_planets = a_planet_list # list of Planet-objects
class Star_cluster:
def __init__ (self):
self.star_list = [] # list of Star-objects
def add(self, Star):
self.star_list.append(Star)
def planets_in_danger(self, stars_list):
result = []
solar_mass = 1.989 * (10**30)
for i in stars_list:
if i.total_mass > 9.5 * solar_mass:
result.append(i)
return result
</code></pre>