Skip to content

Commit af8b1a0

Browse files
committed
push
1 parent c37ce41 commit af8b1a0

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

python_class14/class14.py

+37-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,44 @@
1-
#oops concept
1+
#oops concept: object orianted programming.
22
class student(): #defining class
33
pass
44
s1 = student() # creating object
55
s1.name = "Harry" #assignning values to attributes
66
s1.mark = 95
77
print(s1.name)
88
print(s1.mark)
9+
10+
class employee:
11+
name="chandan"
12+
s1= employee()
13+
print(s1.name)
14+
15+
class car:
16+
color= "blue"
17+
brand = "mercities"
18+
car1 = car()
19+
print(car1.color)
20+
print(car1.brand)
21+
22+
#constructor in python
23+
class supermarket:
24+
def ___init__(self,product_name, product_price, product_color):
25+
self.name = product_name
26+
self.price = product_price
27+
self.color = product_color
28+
s1 = supermarket("tv", "1000", "black")
29+
print(s1.name)
30+
print(s1.price)
31+
print(s1.color)
32+
33+
#inheritance
34+
35+
class Animal:
36+
def Eat(self):
37+
print("i can eat")
38+
class Dog(Animal):
39+
def Bark(self):
40+
print("dog can bark")
41+
d1 = Dog()
42+
d1.Bark()
43+
d1.Eat()
44+
#

0 commit comments

Comments
 (0)