Page 143 - Trackpad_V1_Book 7_Flipbook
P. 143
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.
SOME MORE PROGRAMS
1. Write a program to convert the distance in Kilometres and convert it into Meters.
Tokens and Data Types in Python 141

