class Comlpex init 6

This commit is contained in:
Mert Gör ☭ 2023-06-20 20:15:26 +03:00
parent 2f2b5c1f6b
commit 681064c1cc
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
1 changed files with 16 additions and 0 deletions

16
python-temel/init.6.py Normal file
View File

@ -0,0 +1,16 @@
class Complex:
def __init__(self, real = 0, imag = 0):
self.real = real
self.imag = imag
def disp(self):
print('{}+{}i'.format(self.real, self.imag))
z1 = Complex()
z1.disp()
z2 = Complex(10)
z2.disp()
z3 = Complex(10, 20)
z3.disp()