-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx 11(3-5) .py
More file actions
71 lines (59 loc) · 2.28 KB
/
Copy pathEx 11(3-5) .py
File metadata and controls
71 lines (59 loc) · 2.28 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#%%
print('___________ Ex 11 _______(part 3_5)________ ')
class time:
def sanieshomar(obj):
return obj.minute*60+obj.hour*3600+obj.second
def sub(obj,newtime):
obj.hour -= newtime.hour
obj.minute -= newtime.minute
obj.second -= newtime.second
def kam_kardan(obj,hh,mm,ss):
obj.hour -= hh
obj.minute -= mm
obj.second -= ss
def __add__(obj, obj2): #_____ + _________
obj.hour += obj2.hour
obj.minute += obj2.minute
obj.second += obj2.second
if obj.second>60:
obj.second=obj.second-60
obj.minute=obj.minute+1
if obj.minute>60:
obj.minute = obj.minute - 60
obj.hour = obj.hour + 1
def __ge__(obj, obj2): #_____ >= _________
if obj.minute*60+obj.hour*3600+obj.second>=obj2.minute*60+obj2.hour*3600+obj2.second:
return True
else:
return False
def __gt__(obj, obj2): #_____ > _________
if obj.minute*60+obj.hour*3600+obj.second>obj2.minute*60+obj2.hour*3600+obj2.second:
return True
else:
return False
def __le__(obj, obj2): #_____ <= _________
if obj.minute*60+obj.hour*3600+obj.second<=obj2.minute*60+obj2.hour*3600+obj2.second:
return True
else:
return False
def __lt__(obj, obj2): #_____ < _________
if obj.minute*60+obj.hour*3600+obj.second<obj2.minute*60+obj2.hour*3600+obj2.second:
return True
else:
return False
def __sub__(obj, obj2): #_____ - _________
obj.hour -= obj2.hour
obj.minute -= obj2.minute
obj.second -= obj2.second
if obj.second>60:
obj.second=obj.second-60
obj.minute=obj.minute+1
if obj.minute>60:
obj.minute = obj.minute - 60
obj.hour = obj.hour + 1
def __eq__(obj, obj2): #_____ = _________
if obj.minute*60+obj.hour*3600+obj.second==obj2.minute*60+obj2.hour*3600+obj2.second:
return True
else:
return False
print('___________ Fatemeh Rabie ___________ ')