Page 131 - Trackpad_V4.0_c7_Flpbook
P. 131

Indented block 1
                                                                             Start
                 elif (Test Expression_2):

                     Indented block 2                                                     True
                                                                          if condition 1           block 1
                 elif (Test Expression_3):
                                                                                 False
                     Indented block 3
                                                                                          True
                 else:                                                    if condition 2           block 2

                     Indented block
                                                                                 False


                                                                                          True
                                                                          if condition 3           block 3


                                                                                False
                                                                                                    block


                 Program 7: To check whether a given number is                                                 Stop
                 two-digit number, three-digit number or four-digit number.


                     Program7.py
                  File  Edit  Format   Run   Options   Window     Help

                  num = int(input('Enter a number: '))
                  if(9 < num <= 99):
                      print('Two digit number')
                  elif(99 < num <= 999):
                      print('Three digit number')
                  elif(999 < num <= 9999):
                      print('Four digit number')




                 On running the above program, we get the following output:


                     Output
                  Enter a number: 23
                  Two digit number


                  Enter a number: 345
                  Three digit number



                  Enter a number: 4564
                  Four digit number






                                                                                Conditional  Statements in Python  129
   126   127   128   129   130   131   132   133   134   135   136