Q. How many times will the given loops iterate? Run the code to verify your claim.
[Note: To abort an infinite loop, press Ctrl + C]
(a) | j = 0 while (j < 50): print ("Hello World") |
It will run infinite times. |
(b) | j = 25 while (25 <= j <= 30): print ("Temp variable = ", j) j = j + 1 |
It will run 6 times. |
(c) | j = 25 while (25 <= j < 30): print ("Temp variable =", j) j = j + 1 |
It will run 5 times. |
(d) | # Assume Boolean variable b is not known b = True sum = 0 while b: sum = sum + 5 print (sum) if (b or not b): break |
It will run 1 time. |
(e) | a = 1.0 for i in range (1,4): a = a * 3 print (a) print (j) |
It will run 3 times. |
(f) | a = 1.0 for j in range (4): a = a * j print (a) print (j) |
It will run 4 times. |
(g) | for j in 'abcde': print (j, end = '') if j > 'c': break |
It will run 4 times. |
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )