Computer Science, asked by bpratanavisingh, 1 year ago

Loop coding of python

Answers

Answered by WrathRaiser
0
while <condition here>:
<in loop code here>
<out of loop code here>

example;
i = 0
while i < 10:
i += 1
print i
Answered by zaidghori1997
4

The looping semantics and syntaxes are almost same except for few cases:

1. Python doesnt have do-while loop

2. Python doesnt have brackets. So if you want a couple of statements in a loop you have to space them accordingly

Ex:

i=0

while i<10:

   print(i)

   i=i+1

Both the print statement and incrementation fall under while loop here.

for loop is different than other programming language's for.

for i in range(0,10):

   print(i)

Similar questions