Page 130 - Computing E-Book Grade 7
P. 130

The City School  2021-2022





            # This declares the function called my_function()

            def getMarks():

                Subject=(input(“Enter the subject    name:”))
                Exam=float(input(“Enter the marks obtained in the Exam:”))
                CW=float(input(“Enter the marks obtained in the course work:”))

                Percentage= (Exam+CW)/2

                print(“The Average Percentage of”, Subject,”:”, Percentage)
            # Calling the function
            getMarks()


             5.14.  Error Handling in Python



             A software bug is a coding error that causes an
             unexpected defect in a computer program. In

             other words, if a program does not perform as                    Checkpoint
             intended, it is most likely because of a bug.
                                                                         A list is just an ordered collection of
             There are bugs in software due to unclear or                items which can be of any data type.
             constantly changing requirements, software                  IF statement is a programming

             complexity, programming errors, timelines,                  conditional statement that, if proved
                                                                         true, performs a function or displays
             errors in bug tracking, communication gap,                  information.

             documentation errors, deviation from standards
             etc.

             There are two types of errors/bug in
             python or any other programming

             language.
             Syntax Error: errors in typing the

             commands and variables. Syntax
             errors will be automatically detected

             by the Python IDLE and will show
             you the error in a dialogue box with a

             suggested solution or the line number
             where the mistake has been done:














                                                                                                                130
   125   126   127   128   129   130   131   132   133   134   135