Question 1
3 marksDid your answer earn the marks?
19 original exam-style questions - 9 pages of questions with a full mark scheme - free printable PDF.
SELECT * FROM users WHERE username = 'INPUT_USERNAME' AND password = 'INPUT_PASSWORD';
password <- "Cod3"
length <- LEN(password)
hasDigit <- FALSE
count <- 0
FOR i <- 1 TO length
currentChar <- MID(password, i, 1)
IF currentChar >= "0" AND currentChar <= "9" THEN
hasDigit <- TRUE
ENDIF
count <- count + 1
NEXT i
IF length >= 8 AND hasDigit = TRUE THEN
OUTPUT "Strong"
ELSE
OUTPUT "Weak"
ENDIF| i | currentChar | hasDigit | count |
|---|---|---|---|
| 1 | C | FALSE | 1 |
| 2 | o | FALSE | 2 |
| 3 | d | FALSE | 3 |
| 4 | 3 | TRUE | 4 |
realPassword <- "Sunfl0wer"
attempts <- 0
accessGranted <- FALSE
WHILE attempts < 3 AND accessGranted = FALSE
password <- INPUT("Enter password: ")
IF password = realPassword THEN
accessGranted <- TRUE
ELSE
attempts <- attempts + 1
ENDIF
ENDWHILE
IF accessGranted = TRUE THEN
OUTPUT "Access granted"
ELSE
OUTPUT "Account locked"
ENDIFThis checks your answers in your browser, stores nothing on a server and needs no account.