class Comlpex init 6
This commit is contained in:
parent
2f2b5c1f6b
commit
681064c1cc
1 changed files with 16 additions and 0 deletions
16
python-temel/init.6.py
Normal file
16
python-temel/init.6.py
Normal 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()
|
Loading…
Reference in a new issue