Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 132 - 2610_Springdales_C-7
P. 132

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

                  1.   ‘Sorry!!!, You failed the exam.’, if the marks are less than 35.

                  2.   If the marks are less than or equal to 60, the message displayed is ‘Passed with C grade’.

                  3.   If the marks are greater than 60 and less than or equal to 85, the message displayed is ‘Passed
                     with B grade’.

                  4.  If none of the condition evaluates to true, then, the message displayed is ‘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')

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

                       Output

                    Enter the marks: 60
                    Passed with C grade

                    Enter the marks: 87
                    Passed with A grade

                    Enter the marks: 30
                    Sorry!!!, You failed the exam.

                    Enter the marks: 79
                    Passed with B grade

                            Premium Edition-VII
                    130

| 127 128 129 130 131 132 133 134 135 136 137 |