wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

AP1 Paper 2 Computer Science

Total questions: 16

Worksheet time: 39mins

Name
Class
Date
1.

Identify whether the OCR Reference Language code given is an example of selection or iteration.

Categorize the following

for i = 1 to 10
   print(i)
next i

whilescore != 0
   playgame()
endwhile

if playerHit() then
   score = 0
endif

switch bonus:
   case 0:
    score = 9
   case 1:
    score = 7
   case 2:
    score = 5
endswit

Selection
Iteration
2.


Write pseudocode to increment a value held in a variable score by one.

(a)  

3.


Breaking a complex problem down into smaller problems.

(a)  

4.


Hiding or removing irrelevant details from a problem to reduce the complexity.

(a)  

5.

A restaurant needs an algorithm designing to help employees work out if a customer can have a half price meal or not. It should:

•input required data

•decide if the customer is entitled to a discount

•output the result of the calculation.



Design the algorithm using a flowchart.

6.

Each member of staff that works in a restaurant is given a Staff ID. This is calculated using the following algorithm.

Identify the three different variables used.

7.

Each member of staff that works in a restaurant is given a Staff ID. This is calculated using the following algorithm.

Identify the first three different operators used

8.

  • Casting has been used in this code. Casting means changing data from one data type to another. On what line number has Casting been used?



(a)  

9.
  • Concatenation is the operation of joining character strings end-to-end. For example, the concatenation of "snow" + "ball" is "snowball". The concatenation of "Thompson " + "is" + "Jedi" is "ThompsonisJedi".

  • The concatenation of "Thompson " + "is " + " Jedi". Note the spaces results in "Thompson is Jedi".

  • Concatenation has been used on three lines. Identify in the code where has Concatenation been used?

10.

01 surname = input(“Enter surname”)
02 year = input(“Enter starting year”)

03 staffID = surname + str(year)
04 while staffID.length < 10
05   staffID = staffID + “x”
06 endwhile
07 print(“ID ” + staffID

Complete the trace table for the given algorithm when the surname “Kofi” and the year 2021 are entered.

11.

Jack is writing a program to add up some numbers. His first attempt at the program is shown.

Which arithmetic operator has been used ?

(a)  

12.
  1. Click on the appropriate data type for the following fields:

  2. String

13.
  1. Click on the appropriate data type for the following fields:

  2. Integer

14.
  1. Click on the appropriate data type for the following fields:

  2. Boolean

15.
Question Image

Jack is writing a program to add up some numbers. His first attempt at the program is shown.

Match the ways that the maintainability of this program could be improved.

a)
  • Add comments

1.

//Variable a will store first input

b)
  • Name variables sensibly

2.

total instead of f. Think purpose

c)
  • Use iteration

3.

Use a for loop to get the 5 inputs

16.

Jack decides to improve his program. He wants to be able to input how many numbers to add together each time the algorithm runs, and also wants it to calculate and display the average of these numbers.

Write an algorithm to:

•ask the user to input the quantity of numbers they want to enter and read this value as input

•repeatedly take a number as input, until the quantity of numbers the user input has been entered

•calculate and output the total of these numbers

•calculate and output the average of these numbers.


4 lines