HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →
Live examsInternational live exams are comingTell us which exam you want first. Timed practice papers are open now.See what is coming →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Space Science and Astronomy
  • Earth and Environmental Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
  1. Python Labs
  2. /What kind of orbit is it?
Space Science and AstronomyHardHigh School (11–12)Celestial Mechanics and Spaceflight

What kind of orbit is it?

You will write three functions that read an orbit from one position and one speed. Distances are in AU, speeds in km/s, and GM=887.3 AU km2/s2GM = 887.3\ \text{AU km}^2/\text{s}^2GM=887.3 AU km2/s2 for the Sun.

The idea. The vis-viva equation gives 1/a=2/r−v2/GM1/a = 2/r - v^2/GM1/a=2/r−v2/GM. The escape speed is 2GM/r\sqrt{2GM/r}2GM/r​. A speed below it gives an ellipse, equal to it a parabola, above it a hyperbola.

Your tasks.

  1. In escape_speed, return the escape speed at distance r.
  2. In semi_major_axis, return aaa from r and v. It is negative for a hyperbola.
  3. In kind, return "ellipse", "parabola" or "hyperbola". Treat speeds within 10−9 km/s10^{-9}\ \text{km/s}10−9 km/s of escape as a parabola.

Run it first, just as it is. The checker at the end prints FAIL for each task. Then do the tasks one at a time, and run the program again after each one. A Hint appears under every check that still fails.

When every line says PASS, find the semi-major axis of a probe at 1.5 AU1.5\ \text{AU}1.5 AU moving at 30 km/s30\ \text{km/s}30 km/s.

StemPy LabContributed by StemPy Lab
python
Loading Python runtime…

A worked solution

Run your code once to unlock the worked solution.

Have you tried it?

Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.

Log in to save
← All Labs
← A Kepler's equation solverAn orbit step by step →
More onCelestial Mechanics and Spaceflight

Discussion (0)

Log in to join the discussion.

Loading…

More labs on this topic

  1. Finding L1 by bisectionAdvanced
  2. A Hohmann transfer plannerHard
  3. An orbit step by stepAdvanced
  4. A Kepler's equation solverHard
  5. Orbits from their two endsHard
All labs on this topic →