Logic and computer systems · GCSE · OCR J277 1.2.2, AQA 8525 3.4.5, Edexcel 1CP2 3.1.2 · about 15 min
Magnetic, optical, solid state and cloud storage, and choosing between them.
[1 mark]Why do computers need secondary storage?
[1 mark]Which storage suits a robot that vibrates across a mat?
[1 mark]How does optical storage read data?
[1 mark]What is an advantage of a hard disk over an SSD?
[1 mark]What is a drawback of cloud storage?
[1 mark]Copying a 3000 MB file at 150 MB per second takes how many seconds?
Write choose(needed_gb, no_moving_parts). It returns the name of the cheapest device in devices whose capacity is at least needed_gb, and which has no moving parts if no_moving_parts is True. A device's price in pence is its capacity times its pence per GB. Print one line for each job in jobs, in the form robot logs: SD card.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
# name, capacity in GB, pence per GB, has moving parts
devices = [
("hard disk", 2000, 2, True),
("SSD", 1000, 6, False),
("SD card", 256, 10, False),
("Blu-ray", 50, 4, True),
]
# job, GB needed, needs no moving parts
jobs = [("robot logs", 64, True), ("school backups", 1500, False), ("video editing", 500, True), ("film archive", 40, False)]The hint students can ask for: Look at every device and skip the ones that are too small or that have moving parts when the job forbids them. Of those left, keep the one whose price, its capacity times its price per gigabyte, is lowest.
from bugbot import *
connect()
devices = [
("hard disk", 2000, 2, True),
("SSD", 1000, 6, False),
("SD card", 256, 10, False),
("Blu-ray", 50, 4, True),
]
jobs = [("robot logs", 64, True), ("school backups", 1500, False), ("video editing", 500, True), ("film archive", 40, False)]
def choose(needed_gb, no_moving_parts):
best = None
best_price = 0
for name, capacity, pence, moving in devices:
if capacity < needed_gb or (no_moving_parts and moving):
continue
price = capacity * pence
if best is None or price < best_price:
best = name
best_price = price
return best
for job, gb, still in jobs:
print(f"{job}: {choose(gb, still)}")
Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.