-
Notifications
You must be signed in to change notification settings - Fork 0
/
prog4_Operator.py
34 lines (32 loc) · 1.07 KB
/
prog4_Operator.py
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
class Operator:
def __init__(self):
self.list=[]
def getelement(self):
self.n=int(input("enter max size of list "))
for i in range(self.n):
self.list.append(int(input("enter the element :")))
print(self.list)
def __add__(self,other):
self.new_list=[]
self.zipped_list=zip(self.list,other.list)
for i in self.zipped_list:
self.new_list.append(i[0]+i[1])
print("overloaded addition of lists :",self.new_list)
def __sub__(self,other):
self.new_list=[]
self.zipped_list=zip(self.list,other.list)
for i in self.zipped_list:
self.new_list.append(i[0]-i[1])
print("overloaded substraion of two list :",self.new_list)
def __mul__(self,other):
self.new_list=[]
self.zipped_list=zip(self.list,other.list)
for i in self.zipped_list:
self.new_list.append(i[0]*i[1])
print("overloaded multiplication of lists :",self.new_list)
def __floordiv__(self,other):
self.new_list=[]
self.zipped_list=zip(self.list,other.list)
for i in self.zipped_list:
self.new_list.append(i[0]//i[1])
print("overloaded floor divistion of lists :",self.new_list)