menu

Using Python, write a loop which finds a cumulative and/or summative result from a data set.

To claim this badge, you may either provide evidence from an existing project OR complete the student task. Both assessment options are detailed below.

As well as providing code evidence, you must also answer a series of questions about your loop code.

Project-Based Assessment

For this assessment, you can use one or more loops in your existing project code as evidence of understanding.

You will need to show the code to your mentor and then answer the questions described under “Assessment Questions” below.

Task-Based Assessment

This task is designed to assess your ability to use loops in Python to do find basic summative results for a data set.

You may use web search to complete this task, including the Python documentation and StackOverflow. All research and compilation of the code must be your own work.

You will need to show the code to your mentor and then answer the questions described under “Assessment Questions” below.

  1. Right-click and save the script groundhog-day-task.py from here

  2. Check that you can successfully run the script.

  3. Write your additional code under the Calculations section.

  4. Find the total number of readings in the data set.

  5. Find the maximum and minimum temperature readings.

  6. Find the median temperature.

  7. You must use a loop to find some or all of the required values.

  8. Ensure that the script produces the following output:

Total Readings: 15
Max Temp: 14.1 C
Min Temp: 12.3 C
Median temp: 13.3 C   
Temp Range: 1.799999999999999 C

Assessment Questions

Using either your own project code OR the code from task described above, answer each of the following questions about the loop:

  1. What types of loops are available in Python, and which type is this?
    Name or describe at least two different types of loop.

  2. What determines how many times the loop will run?
    This is the iterable object, it may be a data structure, numerical value or a boolean condition.

  3. What are the variable(s) and values that change in each iteration?
    This includes loop-defined values and your own variables.

  4. What determines when the loop will finish running?
    Identify the termination condition in your code.

  5. How does this loop enable you to find a cumulative or summative result?
    Identify the purpose of the loop and how the code within it requires the use of a loop to achieve the desired result.

  6. How might you implement this loop using a different loop type?
    Describe how you might implement this loop using a different type of loop, and why your choice is the better one. If using another type of loop is not possible, explain why.

View Assessor Guide

Assessor Checklist

  1. Script uses the best-choice loop type.
  2. Uses a well-structured loop.
  3. Loop uses well-scoped variables.
  4. Does not use multiple loops to revisit the same items.
  5. Loop produces correct summative/cumulative output.
  6. Uses clear and sensible naming of variables.
  7. Code includes clear and descriptive comments.
  8. Provided satisfactory answers to assessment questions.