Menu

Search Algorithms - Code Quiz

1. What is the output of this code?

numbers = [4, 8, 15, 16, 23, 42] searchItem = 16 for i in range(len(numbers)): if numbers[i] == searchItem: print(i)
16
2
3
4

2. How many times is the loop body run?

resort = ['Margate', 'Swansea', 'Brighton', 'St Ives', 'Cromer'] townName = 'Brighton' found = False i = 0 while not found and i < len(resort): if townName == resort[i]: found = True i = i + 1
2
4
5
3

Log in or sign-up to access the quiz



Don't have a login?

You can still revise this topic