-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path27_practice_Oops.py
More file actions
52 lines (38 loc) · 1.14 KB
/
27_practice_Oops.py
File metadata and controls
52 lines (38 loc) · 1.14 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
43
44
45
46
47
48
49
50
51
52
# Q1. 2D vector with 3D vector
# class TwoDVector:
# def __init__(self , i , j):
# self.i = i
# self.j = j
# def show(self):
# print(f"The vector is {self.i}i + {self.j}j ")
# class ThreeDVector(TwoDVector):
# def __init__(self , i , j , k):
# super().__init__(i,j)
# self.k = k
# def show(self):
# print(f"The vector is {self.i}i + {self.j}j + {self.k}k ")
# a = TwoDVector(1 , 2)
# a.show()
# b = ThreeDVector(1 , 2 , 3)
# b.show()
# Q2. Add bark to dog
# class Animals:
# pass
# class Pets(Animals):
# pass
# class Dog(Pets):
# @staticmethod
# def bark():
# print("Bow,Bow !!!")
# doggie = Dog()
# doggie.bark()
# Q3. Add a employee class and add salary and increament properties to it
class Employee():
salary = 2345
increament = 30
@property # this decorator gives us freedom to return anything we want
def salaryAfterIncreament(self):
return(self.salary + self.salary * (self.increament/100))
e = Employee()
print(e.salary ,e.increament)
print(e.salaryAfterIncreament)