Computer Science, asked by 1234456upin, 5 months ago

Write a program to perform 'Linear Search' on a list of integers given below, to search for an element input by the user, if it is found display the message "Search successful" otherwise display "Search unsuccessful

51, 7, 29, 11, 15, 120, 30, 45, 89, 79​

Answers

Answered by valeriy69
1

\small\mathsf\color{pink}{Solution\: using\: python\: 3}

def linear_search(item):

numbers = [51, 7, 29, 11, 15, 120, 30, 45, 89, 79]

for number in numbers:

if number == item:

return "Search successful"

return "Search unsuccessful"

if __name__ == "__main__":

item = int(input("item: "))

print(linear_search(item))

\small\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions