class MobilePhone:
def dial(self, phone):
print("mobile phone dialed", phone)
class Fax:
def dial(self, phone):
print("fax dialed", phone)
class NotAPhone:
pass
for obj in [MobilePhone(), Fax(), NotAPhone()]:
obj.dial("053-55555")
mobile phone dialed 053-55555
fax dialed 053-55555
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-6-12fa7657042c> in <module>
1 for obj in [MobilePhone(), Fax(), NotAPhone()]:
----> 2 obj.dial("053-55555")
AttributeError: 'NotAPhone' object has no attribute 'dial'
numpy.dot
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-7-4b1a855c9c7d> in <module>
----> 1 numpy.dot
NameError: name 'numpy' is not defined
import math
math.sqrt(-100)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-9-b5dc45673dc3> in <module>
----> 1 math.sqrt(-100)
ValueError: math domain error