Tutorialslot.com

youtube facebook twitter gmail pinterest

While Loop In Python


Presenting our first control structure. Ordinarily the computer starts with the first line and then goes down from there. Control structures change the order that statements are executed or decide if a certain statement will be run.

Syntax:
while expression:
 statement(s)

Example:
Here's the source for a program that uses the while control structure:
three tables in while loop
a = 0   # FIRST, set the initial value of the variable a to 0(zero).
while a < 31:   # While the value of the variable a is less than 10 do the following:
  a = a + 3   # Increase the value of the variable a by 1, as in: a = a + 1!
  print(a)   # Print to screen what the present value of the variable a is.
    # REPEAT! until the value of the variable a is equal to 9!? See note.

Output:
3
6
9
12
15
18
21
24
27
30



Advertisement Powered By Google Adsense






IF YOU LIKE THIS TUTORIALS PLEASE SHARE

Share on whatsapp

POPULAR TAGS

python python tutorial learn python learning python python code learning java python language python documentation python tutor python basics python download python online python for dummies how to learn python