Page 95 - TP_V5.1_C7_fb
P. 95

ERRORS IN PYTHON PROGRAMS


                 Errors are faults in a program. Errors prevent a program from executing accurately. There can be

                 the following types of errors in a Python program:

                 SYNTAX ERRORS
                 A syntax error will occur when these rules and regulations are violated. For example:








                                                                                              Invalid Syntax
                                                                                              Type P in lowercase for
                                                                                              the correct result.

                                                                                              Invalid Syntax
                                                                                              Parentheses missing








                 LOGICAL ERRORS
                 As the name suggests, these errors are related to the logic of the program. These errors are also
                 known as semantic errors. They cause the program to behave incorrectly. They are the most
                 difficult errors to fix but they do not usually crash the program. For example:

























                                                     Invalid Logic
                                                     The average of 8 and 7 should be
                                                     7.5 Put num1 + num2 in braces as
                                                     (num1+num2) for correct result.






                                                                                    Tokens and Data Types in Python  93
   90   91   92   93   94   95   96   97   98   99   100