For the Python track, this exercise asks you to create a SpaceAge
class (concept:python/classes) that includes methods for all the planets of the solar system.
Methods should follow the naming convention on_<planet name>
.
Each method should return
the age ("on" that planet) in years, rounded to two decimal places:
#creating an instance with one billion seconds, and calling .on_earth().
>>> SpaceAge(1000000000).on_earth()
#This is one billion seconds on Earth in years
31.69
For more information on constructing and using classes, see:
- A First Look at Classes from the Python documentation.
- A Word About names and Objects from the Python documentation.
- Objects, values, and types in the Python data model documentation.
- What is a Class? from Trey Hunners Python Morsels website.