GCSE AQA Computer Science Programming
Questions
Programming Theory Questions
1. State what is meant by the term 'sequence' in programming. [1 mark]
2. Explain the difference between a 'while loop' and a 'for loop'. [2 marks]
3. What is the purpose of a selection statement in programming? [1 mark]
4. Explain what is meant by the term 'iteration' and give an example of when it might be
used in a program. [3 marks]
5. State two ways data can be validated in a program. [2 marks]
6. Explain what is meant by a 'variable' in programming and why they are important. [2
marks]
7. Describe what is meant by 'string concatenation' and provide an example. [2 marks]
8. Explain the purpose of functions/subroutines in programming. [2 marks]
Practical Programming Questions
9. The code below is incomplete:
score = 0
for i in range(10):
answer = input("Enter your answer: ")
if answer == "correct":
# Code missing here
print("Your final score is", score)
Complete the code to add 1 to the score whenever the user enters "correct". [1 mark]
10. Study the following pseudocode:
number = INTEGER(INPUT)
total = 0
WHILE number > 0
total = total + number
number = number - 1
ENDWHILE
OUTPUT total
If the user enters 5, what will be output by this program? Show your working. [3 marks]
11. Look at the following Python code:
def mystery(a, b):
if a > b:
return a
else:
return b
x = mystery(15, 7)
y = mystery(4, 10)
print(x + y)
What will be displayed when this code is executed? Explain your answer. [3 marks]
12. A programmer has written the following pseudocode to check if a number is a prime
number:
number = INTEGER(INPUT)
prime = TRUE
FOR i = 2 TO number - 1
IF number MOD i == 0 THEN
prime = FALSE
ENDIF
NEXT i
IF prime == TRUE THEN
OUTPUT "Prime number"
ELSE
OUTPUT "Not a prime number"
ENDIF
Trace through this algorithm step by step when the input is 7. [4 marks]
13. Write a program in pseudocode or Python that:
Asks the user to input 5 numbers
Stores these numbers in a list/array
Calculates and outputs the average of these numbers
Outputs how many numbers were above the average [6 marks]
14. A cinema charges different prices based on age:
Under 12: £5.00
12-17: £7.50
18 and over: £10.00
Write an algorithm in pseudocode or Python that:
Asks for the customer's age
Displays the ticket price
Includes appropriate input validation to ensure the age is a positive number [5 marks]
15. Write a program in pseudocode or Python that plays a guessing game:
The program should generate a random number between 1 and 100
The user should guess the number
The program should tell the user if their guess is too high or too low
The program should continue until the user guesses correctly
The program should display the number of attempts taken [8 marks]