Skip to content

Commit 7bbb49d

Browse files
Saidev BattulaSaidev Battula
authored andcommitted
Adding Object Oriented Folder with 01_ClassesAndObject Python file
1 parent 282c0fe commit 7bbb49d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

OOP/01_classAndObject.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Complex:
2+
def __init__(self, a, b):
3+
self.a = a
4+
self.b = b
5+
def print(self):
6+
print(f"{self.a}+i{self.b}")
7+
def add(self, c):
8+
self.a += c.a
9+
self.b += c.b
10+
11+
c1 = Complex(10, 20)
12+
print(c1.a, c1.b)
13+
c1.print()
14+
c2 = Complex(20, 30)
15+
c1.add(c2)
16+
c1.print()

0 commit comments

Comments
 (0)