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. /The Earth's energy balance in code
Earth and Environmental ScienceMediumHigh School (9–10)Climate and Climate Change

The Earth's energy balance in code

You will write the three steps of the balance of energy: the sunlight a planet absorbs, the temperature at which it sends out the same power, and the size of its greenhouse effect.

The idea. A planet absorbs S4(1−α)\dfrac{S}{4}(1 - \alpha)4S​(1−α) on average. A body at TTT kelvin radiates σT4\sigma T^4σT4 with σ=5.67×10−8 W/m2/K4\sigma = 5.67 \times 10^{-8}\ \text{W/m}^2\text{/K}^4σ=5.67×10−8 W/m2/K4, so the temperature at balance is (P/σ)1/4(P/\sigma)^{1/4}(P/σ)1/4. The greenhouse effect is the real temperature less the balance temperature.

Your tasks.

  1. In absorbed, return the average power per square metre that a planet absorbs.
  2. In balance_temp, return the temperature in kelvin at which a planet radiates the power p.
  3. In greenhouse_effect, return the real temperature less the balance temperature.

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 temperature with no greenhouse gases for S=1361 W/m2S = 1361\ \text{W/m}^2S=1361 W/m2 and an albedo of 0.600.600.60.

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
← Mountain temperatures and sunlight in codeThe carbon dioxide record in code →
More onClimate and Climate Change

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Sunlight, albedo and the natural greenhouse effectWhat Shapes the Climate of a Place

More labs on this topic

  1. Coasts, rain and fairness in codeMedium
  2. A carbon footprint in codeEasy
  3. Ice, water and the sea level in codeMedium
  4. The carbon dioxide record in codeEasy
Mountain temperatures and sunlight in codeEasy
All labs on this topic →