Skip to content

Commit 13e7f6e

Browse files
committed
PublishFirstEpisode
1 parent 8822455 commit 13e7f6e

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

01 - Introduction to OOP/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
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

01 - Introduction to OOP/main.py

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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))

0 commit comments

Comments
 (0)