Technology and society · GCSE · OCR J277 1.6.1, AQA 8525 3.8, Edexcel 1CP2 5.1.1 · about 25 min
Read the trial log, anonymise it, cost its energy and carbon, and publish a report.
[1 mark]Why does the report use "student 1" instead of names?
[1 mark]Which impacts does the report cover?
[1 mark]170 minutes of a 60 W device. How many kWh?
[1 mark]Anonymised data can sometimes still identify someone. How?
[1 mark]What makes a good conclusion to an impact 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
The hint students can ask for: Read the file and drop the header line. Give each new name the next number and keep its running totals, so the report can talk about students without naming them. Turn the total minutes into energy, then into money and carbon with the rates given.
from bugbot import *
connect()
WATTS = 60
PENCE_PER_KWH = 28
GRAMS_PER_KWH = 190
rows = open("trial.csv").read().strip().split("\n")[1:]
numbers = {}
minutes = {}
distance = {}
total_minutes = 0
for row in rows:
name, email, mins, cm = row.split(",")
if name not in numbers:
numbers[name] = len(numbers) + 1
minutes[name] = 0
distance[name] = 0
minutes[name] = minutes[name] + int(mins)
distance[name] = distance[name] + int(cm)
total_minutes = total_minutes + int(mins)
print("sessions:", len(rows))
print("students:", len(numbers))
print("total minutes:", total_minutes)
for name, n in numbers.items():
print(f"student {n}: {minutes[name]} min, {distance[name]} cm")
kwh = WATTS * total_minutes / 60 / 1000
print(f"energy: {kwh:.2f} kWh")
print(f"cost: £{kwh * PENCE_PER_KWH / 100:.2f}")
print(f"carbon: {round(kwh * GRAMS_PER_KWH)} g CO2")
print("personal data in this report: none")
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.