-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathinheritance.py
More file actions
38 lines (26 loc) · 770 Bytes
/
inheritance.py
File metadata and controls
38 lines (26 loc) · 770 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
##inheritance
## car class blueprint
class Car:
def __init__(self,windows,doors,enginetype):
self.windows=windows
self.doors=doors
self.enginetype=enginetype
def driving(self):
print("Car is ued for driving")
##Audi car is inherting from Car class
class Audi(Car):
def __init__(self,windows,doors,enginetype,horsepower):
super().__init__(windows,doors,enginetype)
self.horsepower=horsepower
def selfdriving(self):
print("IT is a self driving car")
audiq7=Audi(4,5,"Diesel",200)
print(audiq7.horsepower)
print(audiq7.windows)
audiq7.driving()
audiq7.selfdriving()
car1=Car(4,5,"Diesel")
print(car1)
print(audiq7)
print(dir(audiq7))
print(dir(car1))