0% found this document useful (0 votes)
15 views1 page

Linear Search Mark Scheme

The document outlines an algorithm for searching a list of student names for a user-provided name. It specifies the use of string functions to ensure case-insensitive comparison and requires outputs for both found and not found scenarios. The algorithm is scored based on specific criteria related to user input, iteration, selection, and output formatting.

Uploaded by

eva acton
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

Linear Search Mark Scheme

The document outlines an algorithm for searching a list of student names for a user-provided name. It specifies the use of string functions to ensure case-insensitive comparison and requires outputs for both found and not found scenarios. The algorithm is scored based on specific criteria related to user input, iteration, selection, and output formatting.

Uploaded by

eva acton
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

An array called Names_List() contains the names of 5 students who are going on a school trip.

The function string.lower() returns the lower case version of a string.


The function string.upper() returns the upper case version of a string.

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.

nameToSearch = input("Enter a name to look for")


nameFound = False

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")

1 mark for allowing the user to input a name


1 mark for using iteration to search through the list
1 mark for using the loop counter as an array index
1 mark for using selection to compare the name with the list elements
1 mark for converting the name and list to upper or lower case
1 mark for providing an output when the name is found
1 mark for providing an output when the name is not found
1 mark for ensuring the output for the name not being found is outside of the loop

Total 8 marks

You might also like