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. /Magnitudes in code
Space Science and AstronomyMediumHigh School (9–10)Planet Earth in Space

Magnitudes in code

You will write three functions about the brightness of stars.

The idea. A star of magnitude m1m_1m1​ looks 100(m2−m1)/5100^{(m_2 - m_1)/5}100(m2​−m1​)/5 times as bright as a star of magnitude m2m_2m2​. A brightness ratio rrr is a difference of 2.5log⁡10r2.5\log_{10}r2.5log10​r magnitudes. The rough rule N=5000×3m−6N = 5000 \times 3^{m - 6}N=5000×3m−6 counts the stars brighter than magnitude mmm.

Your tasks.

  1. In times_brighter, return how many times as bright star 1 looks as star 2.
  2. In magnitude_gap, return the difference of magnitude for a brightness ratio.
  3. In count_brighter, return the rough number of stars brighter than magnitude m.

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 how many times as bright as a magnitude 666 star the brightest star, Sirius, looks.

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
← Sidereal time in codeChoosing binoculars in code →
More onPlanet Earth in Space

Discussion (0)

Log in to join the discussion.

Loading…

More labs on this topic

  1. Choosing binoculars in codeMedium
  2. Sidereal time in codeMedium
  3. Circumpolar stars in codeEasy
  4. Latitude, longitude and time in codeMedium
  5. Measuring the Earth in codeEasy
All labs on this topic →