Sunday 21 June 2020

19-Python MCQ - 2

What will be the output generated by the following snippet?

a=[5,10,15,20,25]

k=1

i=a[1]+1

j=a[2]+1

m=a[k+1]

print(i,j,m)

(i)            11  15  16

(ii)          11  16  15

(iii)       11  15  15

(iv)       16  11  15



i=a[1]+1 hai
a[1] means a name ki jo list hai uska 2nd element because list me element ki index 0 se start hoti hai so index 1 ka matlab 2nd index hoga

2nd index par 10 likha hai

so i=10+1=11 hoga

j=a[2]+1 hai a[2] means 3rd element so

j=15+1=16 hoga

m=a[k+1]

k ki value 1 di hui hai so

m=a[1+1]
m=a[2]  means 3rd element 
so m=15 hoga

so final ans 11 16 15 yani b wala option sahi hai

No comments:

Post a Comment