-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoop.py
More file actions
42 lines (40 loc) · 1.25 KB
/
oop.py
File metadata and controls
42 lines (40 loc) · 1.25 KB
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
39
40
41
42
# class vehicle:
# #attributes
# colour="black"
# class car(vehicle):
# pass
# print(car.__mro__)
# v1=vehicle()
# c1=car()
# print(c1.colour)
# class vehicle:
# def __init__(self,color,model):
# self.color=color
# self.model=model
# class car(vehicle):
# def __init__(self, color, model):
# super().__init__(color, model)
# class sportscar(car):
# def s_cars(self,color,model):
# return f"color: {color} model: {model} "
# print(sportscar.__mro__)
# c1=sportscar("blue","BMW")
# print(c1.s_cars("blue","BMW"))
# print(c1.color)
class person:
#when using a contructor
# def __init__(self,name,age):
# self.name = name
# self.age = age
def person_info(self,name,age):
return f"hello there my name is {name} and aged {age}"
class company:
def company_info(self,name,location):
return f"Welcome to {name} we are currently based at {location}"
class employee(person,company):
def employee_info(self,name,position,salary):
return f"my name is {name} am the {position} with a salary of {salary}"
#while using a contructors on calling the method using an object it should take arguments
# em = employee("Spedag","Kenya")
em = employee()
print(em.company_info("Spedag","Kenya"))