## Menu Driven Program to show various logical operation on List

def search():

L = []

M = []

N= [ ]

n = int(input(“enter how many elements “))

for i in range(n):

x = int(input(“enter a number”))

L.append(x)

f=0

x = int(input(“enter element to be searched “))

for i in range(n):

if L[i]== x:

f=1

if f==0:

print(“Element does not exits”)

else:

print(“Element exists”)

def highest():

L = []

n = int(input(“Enter N”))

for i in range(n):

x = int(input(“Enter value”))

L.append(x)

max = L[0]

for i in L:

if i>max:

max = i

print(“Greatest is “,max)

def Exchange():

A = [2, 4, 1, 6, 7, 9, 23, 10,55,77]

N = len(A)

print (“The initial array is:”, A)

if N%2==0:

for i in range(int(N/2)): # int(N/2): converting float to int

Tmp = A[i]

A[i] = A[(int(N/2)) + i]

A[int(N/2) + i] = Tmp

print (“The exchanged array is”, A)

else:

print(“N should be Even No”)

def selection():

L = [5,1,5,11,4,9,6,13,2]

n = len(L)

for i in range(n):

min1 = L[i]

pos = i

for j in range (i+1,n):

if L[j] < min1:

min1 = L[j]

pos = j

t=L[i]

L[i]=L[pos]

L[pos]=t

print(L)

ch=’y’

while ch == ‘y’ or ch==’Y’:

print(“1. Linear search = “)

print(“2. find highest element in a list”)

print(“3. Exchange first half with second half of a list”)

print(“4. Sort List using selection sort”)

x = int(input(“Enter choice = “))

if x == 1:

search()

if x == 2:

highest()

if x == 3:

Exchange()

if x == 4:

selection()

ch = input(“\nDo you want to continue Y/N = “)