Prac QUESTION 1
Prac QUESTION 1
if (choice==1):
l=eval(input("Enter the elements of the list:"))
print("The list is:",l)
a=len(l)
print("The number of elements are:",a)
for i in range(0,a):
if(i%2==0):
print("Indexes that have even elements are:",l[i])
if(choice==2):
l=eval(input("Enter the elements of the list:"))
print("The list is:",l)
a=len(l)
print("The number of elements are:",a)
for i in range(0,a):
if(i%2!=0):
l.remove(i)
print("The new list is:",l)
if(choice==3):
l=eval(input("Enter the list:"))
n=int(input("Enter the value of n:"))
for i in range(0,n):
k=l[-1]
for i in range(len(l)-1,0,-1):
l[i]=l[i-1]
l[0]=k
print("The new list is:",l)
if(choice==4):
l=eval(input("Enter the elements of the list:"))
print("The list is:",l)
a=len(l)
print("The number of elements are:",a)
for i in range(0,a):
if(l[i]%2==0):
l[i]=l[i]*2
print("The new list after doubling is:",l)
if(choice==6):
l=eval(input("Enter the list:"))
a=0
for i in l:
if i%10==3:
a=a+i
print("The sum of all the elements with 3 at the end is:",a)
if(choice==7):
l=eval(input("Enter the list:"))
n=int(input("Enter the index number where you want to add:"))
e=int(input("Enter the element you want to add:"))
l.insert(n,e)
print("The new list is:",l)
if(choice==8):
l=eval(input("Enter the list:"))
e=int(input("Enter the element you want to append:"))
l.append(e)
print("The new list is:",l)