Μπορεί να μετατραπεί η παρακάτω while σε ισοδύναμη for;
i=5
while i<10:
i=i+1
print i
for i in range(6,11):
Με τίποτα!
for i in range(5,10):
Μπορεί να μετατραπεί η ακόλουθη while σε for;
i=10
while i>2:
i=i-3
for i in range(10, 2, -3):
for i in range(2, 10, -3):
for i in range(10, 0, -3):
i=4
while i>0:
i=i-1
for i in range(4,0,-1):
for i in range(3,-1,-1):
i=3
while i < 20:
i=i+4
for i in range(20, 4):
for i in range(3, 20, 4):
for i in range(4, 20, 3):
while i < 25:
i=i+5
for i in range(10, 26, 5):
for i in range(10, 21, 5):
for i in range(15, 25, 5):
i=30
while i>19:
i=i-2
for i in range(19, 30, -2):
for i in range(30, 19, -2):
for i in range(30, 17, -2):
while i>15:
χμμ... μάταιος κόπος, i=4
for i in range(4,15):
for i in range(15,4,-1):
i=100
while i>10:
i=i-10
for i in range(100, 20, -10):
for i in range(100, 15, -10):
for i in range(100, 0, -10):