Exam preparation · GCSE · OCR J277 2.2.1, AQA 8525 3.2.2, Edexcel 1CP2 6.1.3 · about 25 min
A robot that asks you questions, marks your answers and tells you what to revise.
[1 mark]Why does the marker lower and strip both answers before comparing?
[1 mark]How does the program know which topic to tell you to revise?
[1 mark]What kind of revision is this program?
[1 mark]What does this program print?
def same(a, b):
return a.strip().lower() == b.strip().lower()
print(same(' SMTP ', 'smtp'), same('IMAP', 'smtp'))[1 mark]Asking the wrong ones again at the end of the quiz is an example of what?
Ask every question in BANK in turn. For each one, print [<topic>] <question>, read the answer with input(), and mark it ignoring capitals and spaces at the ends. Print right for a correct answer, or wrong, it is <answer>. Play a 880 Hz note for right and 220 Hz for wrong, each 0.2 seconds. At the end print score: <n> of <total> and revise: <topic>, the topic with the most wrong answers, then set the LED green if you scored more than half and red if not. The answers are typed for you.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
BANK = [
{"topic": "Networks", "q": "What does DNS turn a domain name into?", "a": "an IP address"},
{"topic": "Data", "q": "How many bits in a byte?", "a": "8"},
{"topic": "Networks", "q": "Which protocol sends email?", "a": "SMTP"},
{"topic": "Security", "q": "What does a firewall check?", "a": "traffic"},
]Plan your program here, then type it in and press Run.