Project: an impact report

Read the trial log, anonymise it, cost its energy and carbon, and publish a report.

F12.9Technology and societyGCSE25 min

Do this lesson in the simulator

A school is deciding whether to buy a class set of robots, and has asked for a report. This project writes it: a program that reads the trial's log, keeps the useful facts, throws away the personal ones, works out the energy and carbon cost, and prints a report anyone could publish. It puts together privacy (F12.2), the environment (F12.5) and weighing up impacts (F12.1).

The log

The trial recorded one line per session. It is on this page, so you can see exactly what the program reads:

name,email,minutes,distance_cm
Sam Patel,sam@school.uk,45,240
Ava Ng,ava@school.uk,30,180
Jo Reilly,jo@school.uk,20,95
Kit Hale,kit@school.uk,50,310
Sam Patel,sam@school.uk,25,140

It holds names and email addresses. The report must not.

What the report needs

  1. How much it was used: the number of sessions, the number of students, and the total minutes.
  2. Nothing personal: students appear as student 1, student 2 and so on, in the order they first appear. No names, no email addresses.
  3. The cost to the environment: the energy for those minutes, its price, and its carbon.
  4. A verdict you could defend.

For the energy, take a robot and its laptop together as 60 W, electricity at 28p a unit, and 190 g of CO2 a unit.

Reading the file

The file is on the page, so a program here can open it like any other:

# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

rows = open("trial.csv").read().strip().split("\n")
print("header:", rows[0])
for line in rows[1:3]:
    name, email, minutes, cm = line.split(",")
    print("session:", name, minutes, "min")

Run this in the simulator

Plan it first

  • read the file and split off the header;
  • give each new name the next student <n> label, remembering the ones you have seen;
  • add up the minutes and the distances;
  • energy in kWh is 60 * total_minutes / 60 / 1000;
  • print the lines the report needs, and never print a name or an email.

Task: write the report

Read trial.csv and print the report, in this order and these exact forms:

  • sessions: <n>
  • students: <n>
  • total minutes: <n>
  • one line per student, student <n>: <minutes> min, <cm> cm, numbered in the order they first appear
  • energy: <kwh> kWh rounded to 2 decimal places
  • cost: £<n> rounded to 2 decimal places
  • carbon: <n> g CO2 rounded to the nearest whole number
  • personal data in this report: none
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()

WATTS = 60
PENCE_PER_KWH = 28
GRAMS_PER_KWH = 190

Challenges

  1. Add the average minutes per session, without naming anyone.
  2. Add a line comparing the carbon with something familiar, such as a car journey.
  3. Write three sentences of verdict for the school: two impacts and a recommendation.