Back to the topic

The mark scheme starts on a new page, so you can print pages one and two for a student and keep the last page yourself. Everything prints in black on white whichever theme you are using.

AQA GCSE CS · 3.2.1 to 3.2.5

Programming Fundamentals

Section A: 10 multiple choice questions, 10 marks. Section B: 5 written questions, 17 marks. Total 27 marks.

Name

Class

Date

Mark  / 27

Section A

Circle the letter of the correct answer. One mark each.

  1. 1What is the result of 17 DIV 5?1
    1. A2
    2. B3
    3. C3.4
    4. D85
  2. 2What is the result of 17 MOD 5?1
    1. A2
    2. B3
    3. C3.4
    4. D12
  3. 3Which data type would be most appropriate for storing a student's average grade of 68.4?1
    1. AReal
    2. BInteger
    3. CBoolean
    4. DString
  4. 4Which of these is true of a REPEAT UNTIL loop but not a WHILE loop?1
    1. AIt is count controlled
    2. BIt can repeat forever
    3. CThe body always runs at least once
    4. DIt uses a condition
  5. 5What does the expression n MOD 2 = 0 test?1
    1. AWhether n is divisible by 10
    2. BWhether n is a whole number
    3. CWhether n is positive
    4. DWhether n is even
  6. 6Why would a programmer declare the number of players in a game as a constant?1
    1. ABecause it is fixed for the whole run and giving it a name makes the code readable and safe to change
    2. BBecause integers must always be constants
    3. CBecause the game will run faster
    4. DBecause constants use less memory than variables
  7. 7A program contains total ← total + price. What happens?1
    1. AAn error occurs because total appears twice
    2. Bprice is copied into total
    3. Ctotal is compared with total plus price
    4. DThe current values of total and price are added and the result is stored back in total
  8. 8Which construct would be most appropriate for processing every item in a list of 40 names?1
    1. ASequence
    2. BCount controlled iteration
    3. CCondition controlled iteration
    4. DSelection
  9. 9What is wrong with IF grade = 'A' OR 'B' THEN?1
    1. Agrade has not been declared
    2. BCharacters cannot be compared
    3. CThe right hand side of the OR is not a complete comparison
    4. DOR is not a valid operator
  10. 10A variable holds the value "25" as a string. What happens if the program tries to add 5 to it?1
    1. AIt gives 255
    2. BIt gives 30
    3. CIt fails or produces unexpected output, because a string is not a number
    4. DIt converts automatically and gives 30 in every language

Section B

Answer in the space provided. The number of marks tells you how many separate points to make.

  1. 1StateState the difference between a variable and a constant.2
  2. 2WriteA program needs to work out how many complete minutes and how many remaining seconds there are in a total of 500 seconds. Write the two expressions needed and give their values.4
  3. 3ExplainExplain the difference between count controlled and condition controlled iteration, giving one example of when each would be used.4
  4. 4ExplainA student writes IF temperature > 30 OR temperature < 10 THEN. Explain what this condition tests and give one situation in which it would be false.3
  5. 5ExplainA program asks the user for their age and then tests whether they can vote. The programmer finds that the test never succeeds, even when 18 is entered. Explain the most likely cause and how it would be corrected.4

Mark scheme

Section A

1B2A3A4C5D6A7D8B9C10C

Section B

1 State the difference between a variable and a constant. 2

One mark for each of the following, to a maximum of 2.

  • A variable can change value while the program is running
  • A constant is fixed when the program is written and cannot change while it runs

Model answer. A variable is a named memory location whose value can be changed while the program is running. A constant is a named value that is set when the program is written and cannot be changed while the program runs.

2 A program needs to work out how many complete minutes and how many remaining seconds there are in a total of 500 seconds. Write the two expressions needed and give their values. 4

One mark for each of the following, to a maximum of 4.

  • Uses DIV for the minutes, for example 500 DIV 60
  • Gives 8 minutes
  • Uses MOD for the seconds, for example 500 MOD 60
  • Gives 20 seconds

Model answer. The number of whole minutes is 500 DIV 60, which is 8, because sixty goes into five hundred eight complete times. The seconds left over are 500 MOD 60, which is 20, because eight lots of sixty is four hundred and eighty and five hundred minus four hundred and eighty is twenty.

3 Explain the difference between count controlled and condition controlled iteration, giving one example of when each would be used. 4

One mark for each of the following, to a maximum of 4.

  • Count controlled iteration repeats a number of times known before the loop starts
  • Condition controlled iteration repeats while a condition is true, for an unknown number of repeats
  • Gives a sensible count controlled example, such as processing every item in a list of known length
  • Gives a sensible condition controlled example, such as repeating until valid input is entered

Model answer. Count controlled iteration repeats a fixed number of times that is known before the loop begins, so a FOR loop is used. Working through all forty names in a list is a count controlled task, because the length of the list is known. Condition controlled iteration repeats for as long as a condition remains true, and the number of repeats is not known in advance. Asking a user to re-enter a password until it matches is condition controlled, because there is no way to know how many attempts they will need.

4 A student writes IF temperature > 30 OR temperature < 10 THEN. Explain what this condition tests and give one situation in which it would be false. 3

One mark for each of the following, to a maximum of 3.

  • It is true when the temperature is above 30
  • It is also true when the temperature is below 10
  • It is false for any value from 10 to 30 inclusive, for example 20

Model answer. The condition uses OR, so it is true when at least one of the two comparisons is true. It is therefore true when the temperature is greater than 30 and true when the temperature is less than 10, which means it detects any temperature outside the comfortable range. It is false for any value from 10 to 30 inclusive, so a temperature of 20 would make it false.

5 A program asks the user for their age and then tests whether they can vote. The programmer finds that the test never succeeds, even when 18 is entered. Explain the most likely cause and how it would be corrected. 4

One mark for each of the following, to a maximum of 4.

  • USERINPUT or the equivalent returns a string
  • The program is comparing a string with an integer, which does not behave as expected
  • The input must be cast or converted to an integer
  • Then the numeric comparison works correctly

Model answer. The most likely cause is that input is returned as a string, so the variable holds the two characters '1' and '8' rather than the number eighteen. Comparing a string with an integer either fails outright or compares character by character, so the test does not behave as intended and never succeeds. The correction is to cast the input to an integer as soon as it is read, for example age ← STRING_TO_INT(USERINPUT), after which the comparison age ≥ 18 works on two numbers and gives the right answer.