Page 103 - modular4.0
P. 103

Chapter Profile
                 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




                 Program 8: To print the message based on the marks entered, display the messages:

                 1.   ‘Sorry!!!, You are failed in the exam’, if the marks are less than 35.
                 2.   If the marks are less than or equal to 60 display the message ‘Passed with C grade’.

                 3.   If the marks are greater than 60 and less than or equal to 85 display the message ‘Passed
                     with B grade’.
                 4.   If none of the conditions  evaluates to true, then display the message  ‘Passed  with A
                     grade’.


                     Program8.py
                  File  Edit  Format  Run   Options   Window    Help

                  #Program to print the message based on the marks entered.
                  my_marks = int(input('Enter the marks: '))

                  if(my_marks < 35):
                      print('Sorry!!!, You failed the exam.')

                  elif(my_marks <= 60):
                      print('Passed with C grade')

                  elif(my_marks > 60 and my_marks <=85):
                      print('Passed with B grade')
                  else:

                      print('Passed with A grade')















                                                                                      Conditional Statements in Python  101
   98   99   100   101   102   103   104   105   106   107   108