You are on page 1of 9

Question 16:

def check_primeno():

n=int(input("enter any no to check whether it is prime or not"))

if n%2 == 1:

print(n,"is a prime number")

else:

print(n," is not a prime number")

check_primeno()
Question 18:

def give_reverseno():

n=input("enter a number to get reverse number as result")

txt=n[::-1]

print(txt,"the number which is the reverse of",n)

give_reverseno()
Question 20:

def great_no():

s=[]

l=int(input("enter how many elements do you want in a list"))

for i in range(0,l):

n = int(input("enter number in the list"))

s.append(n)

print("The display of list",s)

print("The greatest number in the list is",max(s))

great_no()
Question 25

def reverse_list():

s=[]

a=[]

l=[]

size=int(input("enter the no elements in list"))

for i in range(0,size):

n=int(input("enter the elements in the list"))

s.append(n)

print("The display of list",s)

for i in range(0,(size//2)):

a.append(s[i])

for i in range(size//2,size):

l.append(s[i])

l.extend(a)

print("The output list",l)

reverse_list()

output:
Question 26

def reverse2_list():

s=[]

l=[]

size=int(input("enter the no elements in list"))

for i in range(0,size):

n=int(input("enter the elements in the list"))

s.append(n)

print("The display of list",s)

for i in range(size-1,-1,-1):

l.append(s[i])

print(l)

reverse2_list()

Output:
Question 27

def result_list():

s=[]

a=[]

g=[]

size=int(input("enter the no elements in list"))

l=int(input("till which element position the value should be kept constant"))

for i in range(0,size):

n=int(input("enter the elements in the list"))

s.append(n)

print("The display of list",s)

for i in range(0,l):

k=2*s[i]

g.append(k)

for i in range(l,size):

j=3*s[i]

a.append(j)

g.extend(a)

print(g)

h=int(input("enter the element to be replaced"))

d=g.index(h)

o=int(input("enter the element to replace with given no"))

g[d]=o

print(g)

result_list()
Question 28

You might also like