File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ # 01 - Introduction
2
+
3
+ ## This is the First Episode for the OOP Course
4
+
5
+ ### main.py file includes the code we have written till the end of the episode
Original file line number Diff line number Diff line change
1
+ # How to create a class:
2
+ class Item :
3
+ def calculate_total_price (self , x , y ):
4
+ return x * y
5
+
6
+ # How to create an instance of a class
7
+ item1 = Item ()
8
+
9
+ # Assign attributes:
10
+ item1 .name = "Phone"
11
+ item1 .price = 100
12
+ item1 .quantity = 5
13
+
14
+ # Calling methods from instances of a class:
15
+ print (item1 .calculate_total_price (item1 .price , item1 .quantity ))
16
+
17
+ # How to create an instance of a class (We could create as much as instances we'd like to)
18
+ item2 = Item ()
19
+
20
+ # Assign attributes
21
+ item2 .name = "Laptop"
22
+ item2 .price = 1000
23
+ item2 .quantity = 3
24
+
25
+ # Calling methods from instances of a class:
26
+ print (item2 .calculate_total_price (item2 .price , item2 .quantity ))
You can’t perform that action at this time.
0 commit comments