Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 113 - 2615_KEC
P. 113

    elif (conditional expression):
                                 statement(s)
                         else:

                                 statement(s)

                                                       Start

                                                                    True
                                                    if condition 1         Statement 1

                                                          False

                                                                    True
                                                    if condition 2         Statement 2

                                                          False

                                                                    True
                                                    if condition 3         Statement 3

                                                          False
                                                                           Statement

                                                                                         Stop

                     Program 4: To grade a student according to his/her marks.

                         Program4.py

                      File  Edit  Format   Run    Options   Window    Help

                      #Program to grade a student according to his/her marks
                      marks = int(input('Enter marks: '))
                      if(marks >=90):
                          print('Grade A+')
                      elif(marks >=80):
                          print('Grade A')
                      elif(marks >=70):
                          print('Grade B+')
                      elif(marks >=60):
                          print('Grade B')
                      elif(marks >=50):
                          print('You can do better!!!')
                      else:
                          print('You need to work hard!!!')

                                                                                            Control Structures in Python  111

| 108 109 110 111 112 113 114 115 116 117 118 |