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. /A conic from its focus
MathematicsHardHigh School (11–12)Coordinate Geometry › Circles and Conic Sections

A conic from its focus

You will write three functions for the conic lr=1+ecos⁡θ\dfrac{l}{r} = 1 + e\cos\thetarl​=1+ecosθ, with its focus at the pole. Angles are in degrees.

The idea. The distance from the focus in the direction θ\thetaθ is l1+ecos⁡θ\dfrac{l}{1 + e\cos\theta}1+ecosθl​. The curve is an ellipse when e<1e < 1e<1, a parabola when e=1e = 1e=1 and a hyperbola when e>1e > 1e>1. For an ellipse the semi-major axis is l1−e2\dfrac{l}{1 - e^2}1−e2l​.

Your tasks.

  1. Finish r_conic(l, e, deg). Return rrr, or None when 1+ecos⁡θ≤01 + e\cos\theta \le 01+ecosθ≤0.
  2. Finish conic_name(e). Return "ellipse", "parabola" or "hyperbola".
  3. Finish semi_major(l, e). Return l1−e2\dfrac{l}{1 - e^2}1−e2l​ for an ellipse, and None otherwise.

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, check with r_conic that the nearest and farthest distances of r=91+0.5cos⁡θr = \dfrac{9}{1 + 0.5\cos\theta}r=1+0.5cosθ9​ add up to twice semi_major(9, 0.5).

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
← Polar points in PythonFrom roots to coefficients →
More onCoordinate Geometry › Circles and Conic Sections

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Lines, circles and conics in polar formPolar Coordinates in Coordinate Geometry

More labs on this topic

  1. How many common points?Medium
  2. Name the conicEasy
  3. Ellipse and hyperbola numbersEasy
  4. Tangents, normals and focal chordsEasy
  5. Reading a parabola
Easy
All labs on this topic →

Want to go further?

With Standard, you also open 12 more problems, 2 Python labs and 1 extra course. Everything you have used here stays free, always.

Part of our upcoming paid plans.