-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClock.py
More file actions
29 lines (22 loc) · 700 Bytes
/
Clock.py
File metadata and controls
29 lines (22 loc) · 700 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
'''
Class: Clock!
--> Can Measure Time since an Instance of Clock was created!
--> Can make your program wait!
'''
# Imports
import time;
# Class
class Clock:
def __init__(self):
self.startingTime = time.time(); # Initiates
self.takenTime = 0
# Setters
def setStartingTime(self):
self.startingTime = time.time();
# Functions
def wait(self, seconds): # Program Waits
time.sleep(seconds);
def measureTime(self): # Measures Time between call The Function and Creation of Clock Object
self.takenTime = time.time() - self.startingTime;
print(f'Time: {self.takenTime}s.');
return self.takenTime;