print example polymorphism 2

This commit is contained in:
Mert Gör 🇹🇷 2023-07-15 14:50:13 +03:00
parent 63912afe09
commit 26386c4368
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9

View 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)