7
0/10

A program is written to provide information about wind categories based on speed thresholds.

Categories and speed thresholds (in km/h) are stored in parallel arrays. For example, the category "Breeze" is assigned when the speed is from 12 up to but not including 39 km/h.

The user enters an index and the name of the wind category at that array location is displayed. The user can also enter a wind speed, and the corresponding category name is displayed.

Open file Q01.py.

Amend the code to:

  • fix the syntax error on original line 5 thresholds = [0, 12, 39, 74", 118]
  • fix the NameError on original line 6 active = true
  • fix the syntax error on original line 8 wind_speed = 0150
  • fix the syntax error on original line 15 index = int(input("Enter an index: ")
  • fix the NameError on original line 21 category = categs[index]
  • fix the ValueError on original line 22 print(int(category))
  • fix the logic error on original line 26 if ((wind_speed < 0) and (wind_speed > 220)):
  • fix the logic error on original line 29 pointer = 1
  • fix the logic error on original line 35 elif (thresholds[pointer] <= wind_speed):
  • fix the logic error on original line 37 print(categories[pointer - 2])

Do not change the functionality of the given lines of code.

Do not add any additional functionality.

Save your amended code as Q01FINISHED.py

[10]

Develop code Questions

Practise Edexcel GCSE Computer Science Develop code with exam-style questions for GCSE Computer Science. 57 questions 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, matched to the Edexcel GCSE Computer Science (1CP2) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.

PreviousNext

Develop code Questions

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