Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

DSC 430: Python Programming

Assignment 1001: Planet

Which planet is closest to the Earth? The answer might surprise you. In the first part of this assignment, you will create a Planet class. The class should take a radius and a year. For example…

>> mercury = Planet(3.5,88)

For simplicity, we will assume the orbits are perfect circles, are all on the same plane and are whole days. The orbital radius and year length for each planet are given below:

Planet

CM*

Days

Mercury

3.5

88

Venus

6.7

225

Earth

9.3

365

Mars

14.2

687

Jupiter

48.4

4333

Saturn

88.9

10759

Uranus

179

30687

Neptune

288

60190

* 1 CM = 1 million miles

The planet class should have a function, position(), that returns the position of the planet on a specific day. For example…

>> mercury.position(0)

>> 3.5, 0

On day 0, Mercury’s position is at its starting position: x = 3.5 CM, y = 0 CM relative to the Sun at 0, 0. Likewise…

>> mercury.position(22)

>> 0, 3.5

>> mercury.position(33)

>> -2.47, 2.47

>> mercury.position(440)

>> 3.5, 0

Notice that, for a planet, the radius is always the same. Moreover, given a specific day and the length of a year for the planet, you can compute angle

a in this diagram. Thus, with the hypotenuse and a, you should be able to

calculate x and y. Recall “sohcahtoa” from high school.

Finally, create a function that takes two planet objects and a day. It should return the distance between the planets on that day.

>> d = distance(earth, mars, 732)

Record a three minute video in which you run the code. Then, present your code. Specifically, answer the following questions:

· What is the distance between Earth and Mars on day 732?

· How does your position() function work? What trigonometry functions did you need to use?

· How does your distance() function work? Show that you employed top-down design in its implementation.

Submission: Submit a single .py file containing all the code to the D2L. Do not zip or archive the file. Your code must include comments at the top including your name, date, video link, and the honor statement, “I have not given or received any unauthorized assistance on this assignment.” Each function must include a docstring and be commented appropriately.