Python Assignment

Order Description

Assignment instructions: Description: In this assignment, you will practice what you have learned about loops, lists and functions by implementing a database of the planets.

Deliverables:

- You should include the following things submitted as a pdf to schoology:

- Your final python code

- a screenshot that shows the result of printing out what each of your functions return.

Note: Always comment your code! There is no excuse for poorly commented code!

Part 1) Collecting and Organizing Data

a) From a reliable source online, collect the following information for each planet (and Pluto) and Earth's moon: mass, diameter, density, force of gravity, length of day, distance from the sun, average temperature, number of moons. (Hint: try googling "planetary fact sheet -- and don't forget to cite your sources!)

b) Create nine lists -- one list for each category identified in 1a plus a list to store the names of the planets.

c) Combine the lists into a "list of lists".

Part 2) Adding a new body

Ceres (pictured below) is a minor planet and the largest object within the asteroid belt between Mars and Jupiter.

Ceres has the following properties:

mass = 9.3835×1020 kg

diameter = 939.4km

density = 2.162g/cm3

force of gravity: 0.28 m/s/s

day length: 9 hours and 4 minutes

distance from sun: 413 million kilometers

Average Temp: -105.15 C

Number of Moons: 0

a) Create a list that contains the information for Ceres. It should look something like this:

ceres = ["Ceres", .... , -105.15, 0]

b) Write a function that will take a list like the one provided for Ceres and the "list of lists" created in 1c as arguments. The function should return a new "list of lists" but with the elements of the first argument inserted into the "list of lists" by distance from the sun. Use whatever combination of list methods and loops necessary to accomplish this.

Part 3)

a) Write a function that takes a list of lists and a string. The function should return a list of lists that is sorted by whatever property you've passed as a string. For example, if you pass "mass" with the list-of-lists you should get back a list-of-lists that is sorted from least to greatest by mass.

b) Write a function that takes a list-of-lists and the name of a body from the list-of-lists and returns a list containing only the data for that body.

c) Finally, write a function that takes a list-of-lists and the name of a body from the list-of-lists and returns a list of lists without the entry that corresponds with the name passed -- essentially a "delete" function.