Question 3
Edexcel Computer Science June 2025 Paper 2GCSE15 marks
On the specification
- 6.1 Develop code6.2 Program constructs6.5 Operators
Question text
3 A program allows the user to enter a string. If the string is fewer than three characters long, an error message is displayed and the string is not processed. Otherwise, the program adds up the ASCII values for each character in the string. When the total is divisible by four, a four is added to the string. When the total is divisible by five, a five is added to the string. When the total is divisible by both four and five, a four is added to the string. When the total is not divisible by either four or five, a zero is added to the string. The program displays the total value and the changed string. The table shows accurate test results for six inputs. Input Output X String must be three or more characters long XY String must be three or more characters long cup 328 cup4 snow 455 snow5 Ian 280 Ian4 HAT 221 HAT0 <empty> No output, but exits program The lines of code in the program are mixed up. The indentation has been done for you. Open file Q03.py Amend the code to make the program work and produce the correct output. You will need to rearrange the lines. Do not change the functionality of the given lines of code. Do not add any additional functionality. Save your amended code as Q03FINISHED.py (Total for Question 3 = 15 marks)