Errors are issues in a programme that cause it to halt during execution. On the other hand, exceptions are raised when internal events take place that alter the program's usual flow. When a statement is not used in accordance with the guidelines, it is the most frequent cause of an error in a Python programme. The Python interpreter notifies the user right away, typically along with the cause.
There are some types of errors:
n=10 if n>0print(n)
a=5 b=0 division=a/b print(division)
It returns ZeroDivisionError because we are trying to divide a number by zero.
3. IndentationError: In Python indentation refers the white spaces or tabs before any statement. The fact that indentation in python serves purposes other than improving code readability explains why it is crucial. Indentation is only used for readability in other programming languages like C, C++, etc., but it is a fundamental and necessary concept in Python that must be adhered to when writing python code; otherwise, the Python interpreter will throw an IndentationError.
a=1 b=10 if a>10 print(a+b)
Exceptions:
A=[1,5,'t',9]
b=A.index(1)
c=A.index(5)
d=A.index('t')
print("the index number of 1 = ",b)
print("the index number of 5 = ",c)
print("the index number of 't'= ",d)
A=[1,5,'t',9] print(A[4])
It returns IndexError because there doesn't exist any element at index 4 in the given list.
x=[2,4,3] y=5 print(x+y)
x=8 y='4' print(x+y)
D={1:'t',2:'tt','3':'ttt'}
print(D[4])







