File tree 1 file changed +37
-1
lines changed
1 file changed +37
-1
lines changed Original file line number Diff line number Diff line change 1
- #oops concept
1
+ #oops concept: object orianted programming.
2
2
class student (): #defining class
3
3
pass
4
4
s1 = student () # creating object
5
5
s1 .name = "Harry" #assignning values to attributes
6
6
s1 .mark = 95
7
7
print (s1 .name )
8
8
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
+ #
You can’t perform that action at this time.
0 commit comments