Closed roddypr closed 3 years ago
Lets please avoid the word index
and use 'position' instead.
Also:
But I agree your proposed exercise is 100x more relevant than the example. An alternative (or perhaps a followup) might be to access data from a table? (e.g. a table of the most common ants, or the best universities, or the most highly cited papers)
Q7 is now about looping through colours. The attentive students will be able to recognise the code from line 172 and modify it slightly.
What about: Q7: Write a loop that iterates over the colours red, green, blue, yellow, orange, purple, pink and prints out the index (ie the position of the colour in the vector) and the colour itself. This should be done in human-readable format (i.e. "the colour red is in position 1 in the vector", "the colour blue is in position 2 in the vector, and so on). Make sure to indent the code appropriately between the curly brackets.