Q. What will be the outputs produced by following code fragments. First determine output on paper and then verify by running on computer.
Program Code | Dry run (determine output on paper) | Actual output (run code and find out) | |
---|---|---|---|
(a) | for a in 10, 12, 14, 16, 18: print (a) |
10 12 14 16 18 |
10 12 14 16 18 >>> |
(b) | for i in range (5): print (i) |
0 1 2 3 4 |
0 1 2 3 4 >>> |
(c) | for j in range (0,5): print (j) |
0 1 2 3 4 |
0 1 2 3 4 >>> |
(d) | for k in range (3,0): print (k) |
3 2 1 I think my output is wrong. ☹ |
It will not produces any output because there is step value not defined. |
(e) | for c in "Apple": print (c) |
A p p l e |
A p p l e >>> |
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )