Question 2
Edexcel Computer Science June 2023 Paper 2GCSE8 marks
On the specification
- 6.1 Develop code6.3 Data types and structures6.6 Subprograms
Question text
2 A program is written for an exercise routine. It displays the names of warm-up exercises, stored in an array. The user enters a number. That number of exercises is selected randomly from the array and displayed. Open file Q02.py Amend the code to: • fix the syntax error on original line 4 import randum • fix the syntax error on original line 16 for exercise in exerciseTable • complete original line 20 to generate a random number between 0 and 4 index = random. • complete original line 8 to make the exercise names be string data types exerciseTable = ["squats", "planks", pushups, "lunges", "burpees"] • fix the IndexError on original line 21 name = exerciseTable[index + 1] • fix the NameError on original line 22 print (naime) • fix the logic error on original line 19 that causes one less exercise to be printed than is asked for for count in range (numExercises - 1): • use white space to improve the readability of the code. Do not change the functionality of the given lines of code. Do not add any additional functionality. Save your amended code file as Q02FINISHED.py (Total for Question 2 = 8 marks)