A2 Worksheet - The Solar System
A2 Worksheet - The Solar System
Source: docs.python.org/3/tutorial/datastructures.html#more-on-lists
e.g. numbers.append(42)
e.g. values.reverse()
Here are the contents of the planets list, with an index next to each item:
0 1 2 3 4 5 6 7
Task 1 Planets
Mercury, Venus, Mars, Jupiter, and Saturn are visible from Earth. These planets have
been known since antiquity.
By 1930, astronomers had added Uranus (1781), Neptune (1846), and Pluto (1930) to the
list of known planets.
A score of discoveries in the early 2000s led to the demotion of Pluto; since 2006 it is no
longer considered a planet and is classified instead as a dwarf planet.
In this task, you will create a program that recounts this short story about our view of
the planets in our solar system.
Step 1
Open this incomplete program (ncce.io/py-solar-1) in your development environment:
9 print("Planets by 1930:")
10 print(planets)
11 # Remove Pluto from the list
Challenge Steps 2 to 5
Step 2
Complete line 6, so that "Uranus" is added to the end of the list of planets.
Tip: Consult the ‘Operations on lists’ section at the beginning of this worksheet to find out
how to add an item to the end of a list.
Step 3
Run the program to make sure that Uranus is included in the list of planets “known by
1930”.
Example
Note: Use this example to check your program.
Step 4
Complete line 7 and 8, so that "Neptune" and "Pluto"are also added to the end of the
list of planets.
Step 5
Run the program, to make sure that Neptune and Pluto are included in the list of planets
“known by 1930”.
Example
Note: Use this example to check your program.
Step 6
Complete line 11, so that "Pluto" is removed from the list of planets.
Tip: Consult the ‘Operations on lists’ section at the beginning of this worksheet to find out
how to remove an item from a list.
Step 7
Run the program, to make sure that Pluto is not included in the list of planets “after
2006”.
Example
Note: Use this example to check your program.
Step 1
Open this incomplete program (ncce.io/py-solar-2) in your development environment:
Step 2
Complete line 1, so that the list of dwarf planets comprises Ceres, Ataecina, Eris, and
Makemake, in that order.
Tip: Check how the list of planets is created in the first task.
Step 3
Run the program to make sure that the list of dwarf planets is correct.
Example
Note: Use this example to check your program.
Step 4
Complete line 2, so that the second item in the list is assigned the value of "Haumea".
Tip: You will need to assign the new value to the second item of the dwarves list.
Tip: Item numbering starts from 0, so the second item has an index of 1.
Step 5
Run the program to make sure that the second item in the list is Haumea, instead of
Ataecina.
Example
Note: Use this example to check your program.
This should be part of the Dwarf planets:
program’s output: check that the ['Ceres', 'Haumea', 'Eris', 'Makemake']
items and their order are correct.
Challenge Steps 6 to 7
Step 6
Complete line 3, so that "Pluto" is added to the list, as its second item.
Tip: Consult the ‘Operations on lists’ section at the beginning of this worksheet to find out
how to add an item to the end of a list.
Tip: Item numbering starts from 0, so the second item has an index of 1.
Step 7
Run the program to make sure that Pluto is now the second item in the list, preceded by
Ceres and followed by Haumea, Eris, and Makemake, in that order.
Example
Note: Use this example to check your program.
Can you predict what the program will display, before actually running it?