Q. Predict the output of the following code snippet?


(a)

arr = [1, 2, 3, 4, 5, 6]

for i in range(1, 6) :

    arr [i - 1] = arr [i]

for i in range(0, 6) :

    print(arr [ i ], end = " ")


(b)

Numbers = [ 9, 18, 27, 36 ]

for Num in Numbers :

    for N in range (1,Num%8) :

        print (N, "#", end = " ")

    print ()



Answer =

(a)

2 3 4 5 6 6

(b)

1 #
1 # 2 #
1 # 2 # 3 #

>>>

15 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. you have writen wrong question pls correct it
    Q 4 (b) Numbers = [ 9, 18, 27, 36 ]
    for Num in Numbers :
    for N in range (1,Num%8) :
    print (N, "#", end = " ")
    print ()

    ReplyDelete
    Replies
    1. Hii dear, pathwalla's question is correct

      Delete
    2. Check in book...

      Delete
    3. Ig Path walla is correct cuz they solved the same question as the one given in book..

      Delete
  2. ANS will be

    1 #
    1 # 2 #
    1 # 2 # 3 #

    ReplyDelete
  3. answer will be
    -
    1 #
    1 # 2 #
    1 # 2 # 3 #

    ReplyDelete
  4. In first snippet of code, where does the element 1 go, if all elements shift to left, and also how come 6 is printed twice?

    ReplyDelete
    Replies
    1. Please copy the program then run in your idle python. Then try to understand by using print statement.

      Delete
  5. Sir, plzz start u'r u tube channel soon... It's my humble request...

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post