Question 2
Edexcel Computer Science Specimen Paper 2GCSE10 marks
On the specification
- 6.1 Develop code6.4 Input and output
Question text
2 A programmer has started to write a program, but it does not work correctly. The program should ask the user, “Would you like me to sing?”. The user then responds ‘y’ or ‘n’. If the user types ‘y’, then the computer displays the lines of a song. Open file Q02. Amend the code to: • fix the syntax error on line 13 • fix the syntax error on line 15 • fix the syntax error on line 17 • change the identifier x to a more meaningful name • display a suitable question for the user • accept the user’s input of ‘y’ or ‘n’ (no validation is required) • add a comment to explain the effect of the range function’s last parameter, set to −1 • add two uses of white space to aid readability. Do not add any additional functionality. Save your amended code file as Q02FINISHED.py (Total for Question 2 = 10 marks)