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. /Mountain temperatures and sunlight in code
Earth and Environmental ScienceEasyHigh School (9–10)Climate and Climate Change

Mountain temperatures and sunlight in code

You will write three small functions: the temperature up a mountain, the height of the freezing level, and the strength of sunlight at a latitude.

The idea. The temperature at height hhh is T0−ΓhT_0 - \Gamma hT0​−Γh, with a lapse rate Γ\GammaΓ of 6.5 ∘C/km6.5\ ^\circ\text{C/km}6.5 ∘C/km. The freezing level is at T0/ΓT_0/\GammaT0​/Γ. At noon on an equinox the strength of sunlight on flat ground, as a percentage of its strength at the equator, is 100cos⁡φ100 \cos\varphi100cosφ.

Your tasks.

  1. In temp_at, return the temperature at a height h in km above a coast at t0.
  2. In freezing_level, return the height in km at which the air reaches 0 ∘C0\ ^\circ\text{C}0 ∘C.
  3. In sun_percent, return 100cos⁡φ100 \cos\varphi100cosφ, with the latitude lat in degrees.

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 at 4.0 km4.0\ \text{km}4.0 km above a coast where the air is 35 ∘C35\ ^\circ\text{C}35 ∘C.

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
← Faults, slip and magnitude in codeThe Earth's energy balance in code →
More onClimate and Climate Change

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Weather, climate and the controls of climateWhat 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
The Earth's energy balance in codeMedium
All labs on this topic →