Skip to content

Course home

Sign up

Develop code

EasyMediumHard
123456789101112131415
Question 11

A program is needed that must meet the following requirements:

  • accept only integer numbers from 10 to 50, inclusive
  • print 'Out of range' if the input is outside the permitted range. You can assume only numeric inputs will be entered
  • print the input number followed by ' is a multiple of 5', if the number is divisible by 5
  • print the input number followed by ' is not a multiple of 5', if the number is not divisible by 5.

Here is the current, buggy version of the Python code:

score = input("Enter a score: ")

if score < 10 and score > 50:
    print("Out of range")

if score % 5 == 0:
    print(score + " is a multiple of 5")
else:
    print(score + " is not a multiple of 5")

Amend the code to:

  1. Fix the runtime error caused by inputting a valid integer (e.g., entering 15) to ensure proper type conversion.
  2. Fix the logic error in the range condition so that invalid inputs are correctly detected.
  3. Fix the control flow logic error so that the program does not perform division checking if the number is outside the permitted range.
  4. Fix the runtime error and formatting issues in the final print statements so that the input number is correctly concatenated or formatted in the output text.

Do not add any additional functionality or validation.

[13]
Markscheme

Develop code Questions

  1. GCSE
  2. /Computer Science
  3. /Develop code

51 exam-style questions on Edexcel GCSE Computer Science Develop code, covering Decomposition and abstraction to solve problems, Read, write, analyse and refine programs, Converting algorithms into programs, Techniques for readable, maintainable code, Identifying and correcting program errors, and Evaluating program fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank