You will write three small functions that use the pattern for the years of the planets.
The idea. With d the distance from the Sun in AU, the year in Earth years is d × √d. Turned round, the distance in AU is the year raised to the power two thirds, written year ** (2 / 3) in Python.
Your tasks.
year_from_distance, return the year in Earth years for a distance d in AU.distance_from_year, return the distance in AU for a year year in Earth years.percent_off, return by how many percent the pattern's year misses the real year: the difference divided by the real year, times 100. Always give a positive number.Run your code once to unlock the worked solution.
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…