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. /Anomalies, a running mean and a trend
Earth and Environmental ScienceHardHigh School (11–12)Remote Sensing, GIS and Earth Data

Anomalies, a running mean and a trend

Here are twenty yearly mean temperatures of a station, in degrees Celsius, from 2001 to 2020. They were made for this lab. You will turn them into anomalies against a baseline, smooth them, and find the trend.

The idea. An anomaly is a value minus the mean of a baseline. A running mean of five years averages each year with the two years either side, and it is shorter than the record by four values. The trend is the least-squares slope.

Your tasks.

  1. In anomalies, return the list of the anomalies against the mean of the first ten years, 2001 to 2010.
  2. In running_mean, return the list of five-year running means of a list of values.
  3. In trend_per_decade, return the least-squares slope of the temperatures against the years, in degrees Celsius per decade.

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, change the baseline to the last ten years. Which numbers change, and which stay the same?

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
← A carbon dioxide record: trend and cycleNext →
More onRemote Sensing, GIS and Earth Data

Discussion (0)

Log in to join the discussion.

Loading…

Learn it in

  1. Anomalies, baselines and uncertaintyEarth Data with Python: Trends, Anomalies and Models

More labs on this topic

  1. A carbon dioxide record: trend and cycleHard
  2. A raster calculation: slope and floodingHard
  3. Degrees, distances and zonesHard
  4. How often does the satellite pass?Hard
From digital numbers to a map of greenHard
All labs on this topic →