Page 145 - TP_Prime_V2.2_Class8
P. 145

Syntax

                                                 while<condition>:

                                                        statement(s)

                                                        increment/decrement


                 Program 6: To print the numbers from 0 to 20 using the while loop.

                     Program6.py

                  File  Edit  Format   Run    Options   Window    Help                                                      LOOPS IN PYTHON
                  a=0
                  while a<=20:
                      print(a)
                      a=a+1

                                                                                                                          143

                     Output

                  0
                  1
                  2
                  3
                  4
                  5
                  6
                  7
                  8
                  9
                  10
                  11
                  12
                  13
                  14
                  15
                  16
                  17
                  18
                  19
                  20
   140   141   142   143   144   145   146   147   148   149   150