print example polymorphism 2
This commit is contained in:
parent
63912afe09
commit
26386c4368
10
python-temel/print.example.2.py
Normal file
10
python-temel/print.example.2.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
class Complex:
|
||||
def __init__(self, real, imag):
|
||||
self.real = real
|
||||
self.imag = imag
|
||||
|
||||
def __str__(self):
|
||||
return '{}+{}i'.format(self.real, self.imag)
|
||||
|
||||
z = Complex(3, 2)
|
||||
print(z)
|
Loading…
Reference in New Issue
Block a user