You will write three small functions that compare the planets with the Earth and pick out the giants.
The idea. The number of Earths that fit across a planet is its width divided by the Earth's width. The four giant planets are all more than 40 000 km wide, and the rocky planets are all much smaller.
Your tasks.
earths_across, return how many times as wide as the Earth the planet is.is_giant, return True if the planet is more than 40000 km wide, and False if it is not.giants, return a list of the names of the giant planets, in the order of the dictionary.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…