[go: up one dir, main page]

0% found this document useful (0 votes)
27 views10 pages

Errors in Python - 20250206 - 154005 - 0000

The document discusses common errors in Python programming, categorizing them into syntax errors, logical errors, and runtime errors. Syntax errors prevent execution due to incorrect formatting, logical errors produce incorrect outputs without halting the program, and runtime errors occur during execution, causing abnormal termination. Debugging is the process of identifying and correcting these errors to ensure the program runs correctly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views10 pages

Errors in Python - 20250206 - 154005 - 0000

The document discusses common errors in Python programming, categorizing them into syntax errors, logical errors, and runtime errors. Syntax errors prevent execution due to incorrect formatting, logical errors produce incorrect outputs without halting the program, and runtime errors occur during execution, causing abnormal termination. Debugging is the process of identifying and correcting these errors to ensure the program runs correctly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Errors in python

By ajay
PROJECT PREVIEW x
A programmer can make mistakes while writing a program, and
hence, the program may not execute or may generate wrong
output.
The process of identifying and removing such mistakes, also
known
as bugs or errors, from a program is called debugging. Errors
occurring in programs can be categorised as:
i) Syntax errors ii) Logical errors iii) Runtime errors
BACKGROUND OF PROJECT x

Syntax Errors Like other programming languages, Python has its


own rules that determine its syntax. The interpreter interprets the
statements only if it is syntactically (as per the rules of Python)
correct. If any syntax error is present, the interpreter shows error
message(s) and stops the execution there. For example,
parentheses
must be in pairs, so the expression (10 + 12) is syntactically correct,
whereas (7 + 11 is not due to absence of right parenthesis. Such
errors need to be removed before the execution of the program
PROJECT GOALS x
Logical Errors A logical error is a bug in the program that causes it
to behave incorrectly. A logical error produces an undesired output
but without abrupt termination of the execution of the program.
Since the program interprets successfully even when logical errors
are present in it, it is sometimes difficult to identify these errors. The
only evidence to the existence of logical errors is the wrong output.
While working backwards from the output of the program, one can
identify what went wrong. For example, if we wish to find the
average of two numbers 10 and 12 and we write the code as 10 +
12/2, it would run successfully and produce the result 16. Surely, 16
is not the average of 10 and 12. The correct code to find the average
should have been (10 + 12)/2 to give the correct output as 11. Logical
errors are also called semantic errors as they occur when the
meaning of the program (its semantics) is not correct.
Runtime Error A runtime error causes abnormal termination of
program while it is executing. Runtime error is when the statement
is correct syntactically, but the interpreter cannot execute it.
Runtime errors do not appear until after the program starts running
PROCESS x
or executing. For example, we have a statement having division
operation in the program. By mistake, if the denominator entered is
zero then it will give a runtime error like “division by zero”. Let us
look at the program 5-11 showing two types of runtime errors when a
user enters non-integer value or value ‘0’. The program generates
correct output when the user inputs an integer value for num2.
Program 5-11 Example of a program which generates runtime error.
#Program 5-11 #Runtime Errors Example num1 = 10.0 num2 =
int(input("num2 = ")) #if user inputs a string or a zero, it leads to
runtime error print(num1/num2)
RESULT x
RESULT x

Lorem ipsum dolor sit amet, consectetur

60% adipiscing elit. Ut nulla erat, venenatis sed sapien


scelerisque, dapibus venenatis urna. Lorem ipsum
dolor sit amet, consectetur adipiscing elit.
Quisque ac lorem pretium, eleifend nisi nec,
lacinia diam. Mauris dignissim purus nec est
sollicitudin, quis molestie velit tincidunt.
DOCUMENTATION x

Notes 1 Notes 2 Notes 3


CONCLUSION x

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut nulla erat,
venenatis sed sapien scelerisque, dapibus venenatis urna. Lorem ipsum dolor
sit amet, consectetur adipiscing elit. Quisque ac lorem pretium, eleifend nisi
nec, lacinia diam. Mauris dignissim purus nec est sollicitudin, quis molestie velit
tincidunt. Pellentesque commodo varius leo a hendrerit. In a velit auctor,
accumsan diam in, bibendum libero. Nulla facilisi.
THANK YOU
Presented by
Borcelle Group

You might also like