6 exam-style questions with full mark schemes and model answers. Write your own answer and the AI examiner marks it against the mark scheme.
Learn this properly: Variables, Constants, and Data TypesA school sports club needs a program that asks a member to enter their age, then checks that the age is valid (a whole number between 11 and 18 inclusive). If the age is not valid, the program should keep asking until a valid age is entered. Once a valid age is entered, the program should output "Age accepted".
You may answer in AQA-style pseudocode (using <- for assignment, IF ... THEN ... ENDIF, WHILE ... ENDWHILE, USERINPUT and OUTPUT) or any high-level language.
Write a program to do this, and explain how your program ensures only a valid age is accepted. Marks are awarded for a correct input, correct validation of the range, correctly repeating until valid, and a clear explanation. (6 marks)
Study the program below, written in AQA-style pseudocode (<- means assignment).
total <- 0
count <- 0
num <- 4
WHILE num > 1
total <- total + num
count <- count + 1
num <- num - 1
ENDWHILE
OUTPUT total
OUTPUT count
(a) Complete a trace table showing the value of total, count and num after each iteration of the loop. (3 marks)
(b) State the two values that the program outputs. (1 mark)
An array called scores holds the test marks of 5 students. Using AQA-style pseudocode (arrays indexed from 0, <- for assignment), the array is:
scores <- [62, 48, 75, 90, 53]
Write a program that uses a count-controlled loop (a FOR loop) to add up all the marks in the array and output the total. You may use LEN(scores) to get the number of elements. (3 marks)
A program decides what message to show based on a student's percentage mark using selection. The rules are:
"Distinction""Pass""Fail"(a) Write the selection (an IF ... ELSE IF ... ELSE structure) in AQA-style pseudocode or any high-level language. (2 marks)
(b) State what the program would output if mark is 40. (1 mark)
In AQA-style pseudocode, strings are indexed from 0, LEN(string) gives the number of characters, and string[i] gives the character at position i.
A variable is set as follows:
word <- "PYTHON"
(a) State the value returned by LEN(word). (1 mark)
(b) State the character returned by word[2]. (1 mark)
Programs store different kinds of data using different data types.
A program needs to store whether a user is currently logged in — a value that can only be true or false.
Name the most appropriate data type for this value. (1 mark)