Incorrect type
a="sdhuisahd"
print(a+1)
print(None*3)
print(1/0)
print())
accessing a non-existent key in dictionary
a={}
print(a['a'])
encoding error
print('\x93'.encode('ascii'))
when variable not defined
print(a)
when class does not have the attribute defined
class NewType:
pass
inst=NewType()
print(inst.a)
class NewType:
def __init__(self):
self.a=2
inst=NewType()
inst.a=923
print(inst.a)
user defined types’ behaviour achieved with class instances
Here, the class ‘NewType’ is defined with attribute ‘a’ which is initialised to some value. Demonstration of instantiating that class and replacing attribute ‘a’ with some other variable + demonstration of attribute access.