You will write three small functions about the life cycle of a star.
The idea. After the stable stage a star with less mass becomes a red giant, a planetary nebula and a white dwarf. A star with more mass becomes a red supergiant, then a supernova, then a neutron star or a black hole. A rough rule gives the stable life in billions of years: , with the mass in Suns.
Your tasks.
stages, return the list of stages after the stable star. For massive equal to False, return ["red giant", "planetary nebula", "white dwarf"]. For True, return ["red supergiant", "supernova", "neutron star or black hole"].lifetime, return the stable life in billions of years for a mass mass in Suns.longest_lived, return the name of the star with the longest stable life from the dictionary stars of names and masses.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…