Linear Search Mark Scheme
Linear Search Mark Scheme
For example,
“David”.lower() returns the string “david”
“David”.upper() returns the string “DAVID”
Develop an algorithm that searches through the array to find a name chosen by the user.
Your code should:
Allow the user to enter a name to search for.
Search each item in the array to determine whether or not that student is in the list.
If the name is found, tell the user which position in the list that name is.
Output a message to tell the user if the name is not found in the list.
Your code must include one of the functions above to score the highest marks for this question.
for i in range(5):
if nameToSearch.lower() == Names_List[i].lower():
print("The name has been found in position " + str(i))
nameFound = True
if nameFound == False:
print("Name not found")
Total 8 marks