Computer Science
Rewrite following code fragment using while loops :
for i in range(4) :
for j in range(5):
if i + 1 == j or j + 1 == 4 :
print ("+", end = ' ')
else :
print ("o", end = ' ')
print()
Python Control Flow
13 Likes
Answer
i = 0
while i < 4:
j = 0
while j < 5:
if i + 1 == j or j + 1 == 4 :
print ("+", end = ' ')
j += 1
else :
print ("o", end = ' ')
i += 1
print()
Answered By
8 Likes
Related Questions
Rewrite following code fragment using while loops :
min = 0 max = num if num < 0 : min = num max = 0 # compute sum of integers # from min to max for i in range(min, max + 1): sum += i
Rewrite following code fragment using while loops :
for i in range(1, 16) : if i % 3 == 0 : print (i)
Predict the output of the following code fragments:
count = 0 while count < 10: print ("Hello") count += 1
Predict the output of the following code fragments:
x = 10 y = 0 while x > y: print (x, y) x = x - 1 y = y + 1