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. /Orbits from their two ends
Space Science and AstronomyHardHigh School (11–12)Celestial Mechanics and Spaceflight

Orbits from their two ends

You will write three functions that describe an orbit from its perihelion and aphelion distances, in AU.

The idea. a=(q+Q)/2a = (q + Q)/2a=(q+Q)/2 and e=(Q−q)/(Q+q)e = (Q - q)/(Q + q)e=(Q−q)/(Q+q). In solar units the period is T=a3/MT = \sqrt{a^3/M}T=a3/M​ years, with MMM in solar masses.

Your tasks.

  1. In semi_major_axis, return aaa from qqq and QQQ.
  2. In eccentricity, return eee from qqq and QQQ.
  3. In period_years, return the period from qqq, QQQ and the mass MMM of the star.

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 period of an orbit with q=0.3 AUq = 0.3\ \text{AU}q=0.3 AU and Q=4.1 AUQ = 4.1\ \text{AU}Q=4.1 AU round a star of two solar masses.

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
← Rising and setting in codeA Kepler's equation solver →
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. What kind of orbit is it?Hard
  5. A Kepler's equation solverHard
All labs on this topic →