Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLE HELP ME BY PYTHON Part 1: Planetary Density contains a list of the density in grams per cubic centimeter of all the planets, plus

image text in transcribed

PLE HELP ME BY PYTHON

Part 1: Planetary Density contains a list of the density in grams per cubic centimeter of all the planets, plus Pluto. It looks like File density.txt this: Mercury 5.43 Venus 5.25 Earth 5.52 Mars 3.83 Jupiter 1.33 Saturn 0.71 Uranus 1.24 Neptune 1.67 Pluto 2.85 Write a program named Lostname_firstname_density.py that reads the numbers from the file into a list and then calculates and prints, properly labeled: The minimum density The maximum density The average density The median density (Hint: use split() to separate the planet name from the density.) You don't need a list for the first three of these, but you do need a list to calculate the median. Finding the Median To find the median of a group of n numbers, sort them into order. (Hint: use Python's sort method). If n is odd, the median is the middle entry. In a list named data this will be element catatan - 1) // 2] . Note the use of // to do integer division. If nis even, the median is the average of the numbers "surrounding the middle. For a list named data, this is (data[(n // 2)] = data[(n // 2) - 1]) / 2.0. Your program must work for a file with any number of entries. The file I am providing happens to have an odd number of entries, but if I gave you a similar file for the major moons of Saturn, it would have an even number of entries, and your program would still have to correctly calculate the statistics for that file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions