+ 1
I am making small program(timer) with great and counting the last event but the time goes repeating
import os import time s=0 m=0 while s<= 60 : os.system( 'cls' ) print (m, 'Minutes' , s, 'Second time.sleep( 1) s+= 1 if s== 60: m+= 1 s= 0
5 Réponses
+ 1
While there is technically nothing wrong with your method of implementation the accuracy may not be exactly what you are hoping for. time.sleep() is not 100% exact. Python will sleep and check to see if the defined amount of time has passed before continuing. At the beginning of the execution that will be fine but eventually all the extra milliseconds will compound to throw your timer off. I would recommend looking into a delta time function. With every loop check to see if the time is greater than the last time an update occurred.
0
<!DOCTYPE html>
<html>
<head>
<script>
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = checkTime(m);
s = checkTime(s);
document.getElementById('txt').innerHTML =
h + ":" + m + ":" + s;
var t = setTimeout(startTime, 500);
}
function checkTime(i) {
if (i < 010) {i = "0" + i};
return i;
0
bro i was making clock but the clock was not appearing totally
0
what is wrong bro with my code and what do you think i have to check on, I am using PC and chrome as browser
0
what is wrong bro with my code and what do you think i have to check on, I am using PC and chrome as browser