Question

I want to have a code that can pick whichever two planets in the solar system and find the distance of them no matter where in their orbit they are, but I keep getting errors. Can someone please help me fix it?

f rom scipy import exp, pi, absolute, linspace import matplotlib. Ryplot as plt planet-I input (Which planet do you want toreturn planet 1 x linspace(0, 20, 1000) plt plotx, distance(x)) plt.xlabel(Time in years) plt.vlabel(Distance in AU) planeif planet 1str (earth): print(str(earth)) elif planet-1 # Mercury print(mercury) venus : elif planet 1 print(venus) print

f rom scipy import exp, pi, absolute, linspace import matplotlib. Ryplot as plt planet-I input ('Which planet do you want to pick for planet 1?") planet_2 input ('which planet do you want to pick for planet 27') distance - input ('are you sure you want to find the distance of these two planets?') def mercury(t): r-0.3871 #semi-major axis of Mercury orbit in AU return r*exp.(2*pi+1j*(r**-0.4*t)) def venus(t): r = 0.7233 # semi-major axis of Venus orbit in AU return rxexp (2*pi*lj*(r*-0.7*t)) return exp(2xpi*1jxt) r:1.524 # semi-major axis of Mars orbit inAu def earth(t): def mars(t): return rxexp(2xpi*1j(r**-1.5*t)) def jupiter(t): r-5.203,# sem i-major of.Jupiter orbit axis in-AU return r*exp(2*pi*1j*(r**-5.2*t)) def saturn(t): 9.539 # semi-major axis of Saturn orbit in AU r return rxexp(2xpi*1j*(r*x-9.5xt)) def uranus(t): r = 19.1914 # semi-major axis-of. Uranus orbit in AU return rexp(2xpi*1j*(r**-19.2*t)) def neptune(t): 30.0611 #semi-major axis of Neptune orbit in AU r return r*exp(2*pix1j*(rx-30.1*t)) def distance(t): def yes(t): def no(t): return absolute(str(planet_ 1) str(planet_2)) return distance return planet 1 x linspace(e, 20, 1000) pit:plot.(x, distance(x)) plt xlabel("Time in years") plt-ylabel("Distance in AU") pit.ylim(, 3) pit show) planet-1 = input ("which planet do you want to pick for planet 1?i) if planet l str('earth):
return planet 1 x linspace(0, 20, 1000) plt plotx, distance(x)) plt.xlabel("Time in years) plt.vlabel("Distance in AU") planet 1- input('which planet do you want to pick for planet 1?) if planet 1str('earth'): print(str(earth)) elif planet 1mercury: print(mercury) elif planet 1venus: print(venus) elif planet-1 =- 'mars': elif planet 1jupiter': elif planet-1 'saturn'; elif planet 1 uranus' elif planet-1-= 'neptune": print(mars) print(jupiter) print(saturn) print(uranus) print (neptune) planet-2 = input ('which planet do you want to pick for planet 2? if planet 2earth': elif planet 2 str( 'mercury'): elif planet 2'venus': elif planet 2mars': elif planet,2 #- 'Jupiter'; print(earth) print(str(mercury)) print(venus) print(mars) print (jupiter) elif planet 2'saturn':
if planet 1str ('earth): print(str(earth)) elif planet-1 # 'Mercury print(mercury) venus ': elif planet 1 print(venus) print (mars) elif planet 1jupiter: print (jupiter) elif planet 1'saturn print(saturn) elif planet 1uranus': print(uranus) elif planet 1 neptune: print (neptune) input ('which planet do you want to pick for planet 27) planet 2 if planet 2earth print (earth) elif planet2str('mercury): elif planet-2 ## "venus": elif planet-2 'mars': etif planet 2 jupiter': elif planet 2saturn' elif planet-2-# 'uranus'; elif planet 2'neptune' print(str(mercury)) print(venus) print(mars) print(jupiter) print(saturn) print(uranus) print(neptune) distance- input ('are you sure you want to find the distance of these two planets?') if yes print(str(distance)) if no: printiplanet 1)
0 0
Add a comment Improve this question Transcribed image text
Answer #1

You need to import the correct packages first.

import matplotlib.pyplot as plt

import math

include these 2 lines at beginning of code and it will work fine.

If it still does not work, try installing the packages first since they might be missing from your system.

Add a comment
Know the answer?
Add Answer to:
I want to have a code that can pick whichever two planets in the solar system and find the distance of them no matter where in their orbit they are, but I keep getting errors. Can someone please help...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Can someone help me with this question, I do not know how to do the long-distance...

    Can someone help me with this question, I do not know how to do the long-distance in excel. If you could show me the Excel data as well that would be great. retention 10.18 The following are the average distances of the planets in the solar system from the 25 Distance (millions of miles) 47.163 67.235 92.960 141.61 313.00 483.60 886.70 1783.0 2794.0 3666.0 Planet No. Planet Mercury Venus Earth Mars Asteroids Jupiter Saturn Uranus Neptune Pluto 4 10 (a)...

  • Before you start doing this code Read carefully there is a format that you have to...

    Before you start doing this code Read carefully there is a format that you have to follow HERE IS THE FORMAT YOU MUST USE FOR HW #2 - NOTE THE IF ELSE IF...not IF IF IF HW #2 Format : Instructions: This program will generate some information for a user about interplanetary travel (pretend we can travel easily to other planets for this problem). This program will perform calculations concerning weight on various planets as well as travel time between...

  • Table 13.1 Solar system data (in SI units and relative to Earth) Orbit eccentricity Mass Equatorial...

    Table 13.1 Solar system data (in SI units and relative to Earth) Orbit eccentricity Mass Equatorial radius semimajor axis period (a^) (years) 30 Sun 2.0 X 10 3.3 × 10 Mercury 3.30 X 1023 Venus 4.87 X 1024 Earth Mars Jupiter 1.90 x 1027318 Saturn 5.68 × 1026 95.2 Uranus 8.68 X 1014.5 Neptune 1.02 x 102617.1 Pluto 2.440 ×106 6.052 X 106 6.378 X 106 3.396 × 106 5.79×1010 1.082 x 1011 1.496 × 1011 2.279 ×1011 11.2 7.783...

  • Please use the formulate sheet and show all steps to make sure the question is worth...

    Please use the formulate sheet and show all steps to make sure the question is worth any points a) The initial ratio of deuterium (D) to hydrogen (H) in a planet's atmosphere was 175000; however, the present ratio is 1/1500 and the initial and final abundances of D are 5 x 10° atoms per m3 and 9 x 106 atoms per m2, respectively. What fraction of deuterium has been lost, and what fraction of hydrogen has been lost in this...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT