Jul-20-2019, 04:30 PM
(This post was last modified: Jul-20-2019, 04:30 PM by PoetLearnsPython.)
Hey, I'm new here so if I break any rules, feel free to scold me.
Anyway, I was learning how to program a simple timer from a YouTube video. I got everything to work, and tweaked a few things myself. But when I compared it with an independent timer (phone and computer timer), I noticed that it runs a bit slower. By the two minute mark it's about 15 seconds behind the independent timer. Is there a way to improve this or would I have to completely start from scratch to get a more accurate one?
Oh, and I'm running 3.7.
Here's the code:
Anyway, I was learning how to program a simple timer from a YouTube video. I got everything to work, and tweaked a few things myself. But when I compared it with an independent timer (phone and computer timer), I noticed that it runs a bit slower. By the two minute mark it's about 15 seconds behind the independent timer. Is there a way to improve this or would I have to completely start from scratch to get a more accurate one?
Oh, and I'm running 3.7.
Here's the code:
import time from os import system seconds = int(0) minutes = int(0) hours = int(0) run = input("Enter R to run the program\n") while run.lower()=="r": seconds = (seconds + 1) if seconds > 59: seconds = 0 minutes += 1 if minutes > 59: minutes = 0 hours += 1 system('cls') print(hours,":", minutes,":",seconds) time.sleep(1)