Programming Examples

Write a program that takes as input a list having a mix of 10 positive numbers and a key value.


Write a program that takes as input a list having a mix of 10 positive numbers and a key value.

Apply linear search to find whether the key is present in the list or not.

If input is: [10, 50, 30, 70, 80, 20, 90, 40], key = 30

Then output should be: Yes

If input is: [10, 50, 30, 70, 80, 20, 90, 40], key = 15

Then output should be: No

numbers = eval(input("Enter numbers separated by space: "))
key = int(input("Enter key to search: "))
found = False
for num in numbers:
    if num == key:
        found = True
        break
if found:
    print("Yes")
else:
    print("No")

Output

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad