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
  • 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. /The early universe in code
PhysicsMediumHigh School (11–12)Astrophysics

The early universe in code

You will write three functions about the hot early universe.

The idea. The CMB is at 2.725 K2.725\ \text{K}2.725 K today and its temperature is 2.725(1+z)2.725(1 + z)2.725(1+z) kelvin at redshift zzz. Wien's law gives the peak, λ=2.898×10−3/T\lambda = 2.898 \times 10^{-3}/Tλ=2.898×10−3/T metres. The critical density is 3H2/(8πG)3H^2/(8\pi G)3H2/(8πG) with HHH in s−1\text{s}^{-1}s−1.

Your tasks.

  1. In temperature, return the CMB temperature at redshift z.
  2. In peak_mm, return the peak wavelength in millimetres for a temperature T.
  3. In critical_density, return the critical density in kg/m3\text{kg/m}^3kg/m3 for H0 in km/s per Mpc.

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 redshift at which the CMB was at 273 K273\ \text{K}273 K, the freezing point of water.

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
← Hubble's law in codeNext →
More onAstrophysics

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. The Big Bang, the cosmic microwave background and dark matterCosmology: Redshift, Hubble's Law and the Big Bang

More labs on this topic

  1. Hubble's law in codeMedium
  2. Finding exoplanets in codeMedium
  3. Main-sequence stars in codeMedium
  4. Stars as black bodies in codeMedium
Distances to the stars in codeMedium
All labs on this topic →