Question 3

Edexcel Computer Science Specimen Paper 2GCSE13 marks

On the specification

6.1 Develop code6.4 Input and output6.5 Operators
Question text

3 A program is needed that must meet the following requirements: • accept only numbers from 1 to 20, inclusive • print ‘invalid input’ if the input is outside the permitted range. You can assume only numbers will be entered • print the input number followed by ‘is even’, if the number is even • print the input number followed by ‘is odd’, if the number is odd. Open file Q03. Amend the code to: • fix the runtime error caused by inputting a valid number such as 4 (no other validation is required) • fix the logic errors that cause incorrect or no outputs for acceptable numbers from 1 to 20, inclusive • fix the logic error that causes the program to execute, even if a number outside the permitted range is entered • make all output messages match the requirements listed above. Do not add any additional functionality. Save your amended code file as Q03FINISHED.py (Total for Question 3 = 13 marks)