Robust programs · GCSE · OCR J277 2.3.1, AQA 8525 3.2.11, Edexcel 1CP2 6.4.4 · about 15 min
Usernames and passwords, limiting attempts, and stronger ways to prove who someone is.
[1 mark]What is authentication?
[1 mark]What does this program print?
operators = {"ada": "robot42", "alan": "turing1"}
name, password = "ada", "turing1"
print(name in operators and operators[name] == password)[1 mark]Why should a login say "access denied" rather than "no such user"?
[1 mark]Why limit the number of login attempts?
[1 mark]A password and a code sent to your phone is an example of what?
Use operators = {"ada": "robot42", "alan": "turing1"}. Ask Username? and Password? up to three times. For each wrong pair print access denied. When a pair is right, print welcome <name>, turn the LED green and drive 20 cm forward. The task types alan and wrong, then alan and turing1.
# the two lines every program starts with: the commands, then the robot
from bugbot import *
connect()
operators = {"ada": "robot42", "alan": "turing1"}Plan your program here, then type it in and press Run.