Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9281d73

Browse files
committed
add class examples
1 parent 65bfe39 commit 9281d73

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea/

objectorientedpython.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Basic Class Definition
2+
class Monitor():
3+
def __init__(self, model):
4+
self.model = model
5+
6+
7+
# Create Instances Of The Class
8+
monitor1 = Monitor("Samsung")
9+
monitor2 = Monitor("Viewsonic")
10+
11+
# Print The Class and Property
12+
print(monitor1)
13+
print(monitor1.model)
14+
# <__main__.Monitor object at 0x01702E98>
15+
# Samsung
16+
17+
18+
print(monitor2)
19+
print(monitor2.model)
20+
# <__main__.Monitor object at 0x01042F28>
21+
# Viewsonic

0 commit comments

Comments
 (0)