Skip to content

Course home

Sign up

Develop code

EasyMediumHard
123456789101112131415
Question 2

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]
Markscheme

Develop code Questions

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

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.

Question bank