0% found this document useful (0 votes)
1 views8 pages

Errors in Python

Uploaded by

sehr.padi24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views8 pages

Errors in Python

Uploaded by

sehr.padi24
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

5 Types of Errors

in Python

By- Sehr Padi 7E


Definition: Errors in code
structure or format.

1. Syntax Example: print "Hello"


Errors (missing parentheses).

Fix: Correct syntax


mistakes.
Definition: Python relies on
indentation to define code blocks.

Example:
2.
Indentation def greet():
Errors
print("Hello") # Indented
incorrectly.

Fix: Align code with proper


indentation.
Definition: Occur when a variable or
function is used before being defined.

Example:
3. Name
Errors print(x) # x is not defined.

Fix: Define variables before use.


Definition: Occur when an operation or
function is applied to the wrong data
type.

Example:
4. Type
Errors print("Hello" + 5) # Cannot add string
and integer.

Fix: Use correct data types or convert


them.
Definition: Occur when a function gets
an argument of the right type but an
inappropriate value.

Example:
5. Value
Errors int("abc") # Cannot convert letters to
integers.

Fix: Provide valid input values.


• Syntax, Indentation, Name,
Type, and Value errors are
common in Python.

• Understanding and fixing


Conclusion these errors improves code
reliability.

• Practice debugging to
become a proficient
programmer.
Thank you

You might also like