10000 init · ammarlodhi255/python-src@ddb46d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit ddb46d2

Browse files
committed
init
1 parent d8fcaaa commit ddb46d2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

OOP/class_and_static_methods.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Car:
2+
3+
num_of_chairs = 4 # Class Variable
4+
5+
def __init__(self, color, model, speed):
6+
self.color = color
7+
self.model = model
8+
self.speed = speed
9+
10+
def show_details(self):
11+
print(
12+
f'Color: {self.color}\nSpeed: {self.speed}\nModel: {self.model}\n')
13+
14+
def show_num_of_chairs(self):
15+
print(Car.num_of_chairs) # Access class variable
16+
17+

0 commit comments

Comments
 (0)
0