An algorithm is shown in the following code block:
1 # -----
2 # Global arrays and state variables
3 # -----
4 majorCities = ["London", "Paris", "Tokyo", "New York", "Cairo"]
5 currentCity = ""
6
7 # -----
8 # Main program implementation
9 # -----
10
11
12 for city in majorCities:
13 print(city)
14
15 currentCity = input("Enter a city name: ")
16 while (currentCity != "Exit"):
17 if (currentCity == "Tokyo"):
18 print("Tokyo is incredibly large!")
19 else:
20 print("I would love to visit " + currentCity)
21
22 currentCity = input("Enter another city name: ")
Give the line number where the algorithm first starts to iterate over every item in a data structure.
50 exam-style questions on Edexcel GCSE Computer Science Constructs, covering Structural components of programs and Writing programs with control constructs. Each one has a worked solution and a mark scheme showing where the marks go.