A programmer has started to write a program for an automated greenhouse irrigation system, but it does not work correctly. The program should ask the user, "Do you want to initiate the watering cycle?". The user then responds 'y' or 'n'. If the user types 'y', then the computer displays the remaining water level in litres from 12 down to 3, in steps of 3 (i.e. 12, 9, 6, 3), followed by "Tank empty!".
Below is the buggy source code:
s = input()
if s == "y"
for litres in range(12, 0 -3):
print(litres)
print("Tank empty!"
Amend the code to:
s to a more meaningful namerange function's last parameter, set to -3Do not add any additional functionality.
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.