An algorithm is designed to display a list of musical instruments available for a band workshop.
1 # ----- Global variables -----
2 bandInstruments = ["Guitar", "Bass", "Drums", "Keyboard"]
3
4 # ----- Subprograms -----
5 def showInstruments (itemList):
6 for i in range (0, len (itemList)):
7 print (i, itemList[i])
8
9 # ----- Main Program -----
10 response = input ("Do you want to see the instruments? ")
11 if ((response == "yes") or (response == "Yes")):
12 showInstruments (bandInstruments)
13 else:
14 print ("Goodbye")
State the type of data structure used to hold the band instruments inside the variable bandInstruments in this algorithm.
159 exam-style questions on Edexcel GCSE Computer Science Algorithms, covering Constructs for solving problems, Variables, constants and data structures, Arithmetic, relational and logical operators, Tracing algorithm output with trace tables, Types of error and correcting logic errors, Standard algorithms (sorts and searches), and Evaluating algorithm fitness and efficiency. Each one has a worked solution and a mark scheme showing where the marks go.