Q1.what is the output of code.
r=[2,1,0,3]
for i in r:
r[s]=0
print(r)
output
first r[2]=0
so list [2,1,0,3]
next r[1]=0
so list[2,0,0,3]
nextr[0]=0
so list [0,0,0,3]
next r[3]=0
so list[0,0,0,0]
[0,0,0,0]
Q2.Program to find common b/w three sorted list.
def fc(a,b,c):
n=len(a)
m=len(b)
k=len(c)
for i in range(0,n):
for j in range(0,m):
if(a[i]==b[j]):
for k in range(0,k):
if(a[i]==c[k]):
print(a[i])
a=[1,2,3]
b=[2,3,4]
c=[2,3,5]
fc(a,b,c)
Q3.what is the out of code
r=[1,2,2,1]
for i in r:
r[s]=1
print(r)
output
[1,1,1,1]
Q4.Program to find subarray from array.
def suba(a):
n=len(a)
for i in range(0,n+1):
for j in range(i,n+1):
for k in range(i,j):
print(a[k], end="")
print()
a=[1,2,3,4]
suba(a)
Q5. what is the output of code
r=[1,2,3,4]
for i in r:
r[i]=0
print(r)
output
[0, 0, 3, 0]
0 Comments