trds

class StopWatch - 20.02.2021

Jan 20th, 2021 (edited)
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import time
  2. class StopWatch:
  3.     def __init__(self, stop):
  4.         self.__startTime = time.time ()
  5.         self.__stopTime = stop
  6.     def __repr__(self):
  7.         return "Cronometrul porneste la {} si se opreste la {}".format(self.__startTime, self.__stopTime)
  8.     def start(self):
  9.         self.__startTime = time.time()
  10.     def stop(self):
  11.         self.__stopTime = time.time()
  12.     def getElapsedTime(self):
  13.         dif = self.__stopTime - self.__startTime
  14.         return dif
  15.  
  16. t=StopWatch(1823)
  17. print(t)
  18. timer = StopWatch (1970)
  19. timer.start()
  20. s=0
  21. for i in range (1,1000001):
  22.     s=s+1
  23. print("s =", s)
  24. timer.stop()
  25. print(timer.getElapsedTime())
Add Comment
Please, Sign In to add comment