Question 1

Edexcel Computer Science June 2024 Paper 2GCSE10 marks

On the specification

6.1 Develop code6.2 Program constructs6.3 Data types and structures
Question text

1 A program is written to provide information about the rainbow. Colours and wavelengths are stored in arrays. For example, the colour Violet is produced when the wavelength is from 380 to 424 The user enters an index and the colour at that array location is displayed. The user enters a wavelength and the colour for that wavelength is displayed. Open file Q01.py Amend the code to: • fix the syntax error on original line 5 waveTable = [380, 425, 450, 492, 577, 597", 622] • fix the NameError on original line 6 found = false • fix the syntax error on original line 8 wavelength = 0123 • fix the syntax error on original line 15 index = int (input ("Enter an index: ") • fix the NameError on original line 21 color = rainbow[index] • fix the ValueError on original line 22 print (int (colour)) • fix the logic error on original line 26 if ((wavelength < 380) and (wavelength > 622)): • fix the logic error on original line 29 index = 1 • fix the logic error on original line 35 elif (waveTable[index] <= wavelength): • fix the logic error on original line 37 print (rainbow[index - 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 (Total for Question 1 = 10 marks)