clock

How to make a function that take one parameter and boolean in Python

How to make a function that take one parameter and boolean in Python Question: How to make a function hours that receives seconds from 00:00 (midnight) and a boolean parameter that is True to return a 24h-based hour, and False for a 12h-based hour, and returns hours (as a 12h or 24h clock depending on …

Total answers: 2

stop the clock within the time limit in tkinter python

stop the clock within the time limit in tkinter python Question: I want to stop clock within the time limit, here i have given 5 seconds but the clock is not stopping, kindly help. import tkinter as tk from tkinter.constants import * def start(): global hours, minutes, seconds if hours == 4: return seconds -= …

Total answers: 2

How do I iterate through a list of dictionaries?

How do I iterate through a list of dictionaries? Question: I need to take an inputted time, for example "12:20", and print a 5×3 ASCII clock representation of it. But I don’t know how how iterate through a list of dictionaries, which I think is the simplest way to solve this problem. time = input("enter …

Total answers: 1

why do i keep getting this error and how do i solve it

why do i keep getting this error and how do i solve it Question: So i have this massive python code but i cant get it to work. It keeps saying: UnboundLocalError: local variable ‘secondnum’ referenced before assignment This problem is actually solved now thanks for the help but the program still doesnt seem to …

Total answers: 2

How datetime.datetime.now() works without internet connection?

How datetime.datetime.now() works without internet connection? Question: In python, by importing datetime module and using various functions of class datetime.datetime we could get basic dates with formatting and even date arithmetic for deployment. For example, datetime.datetime.now() will return today’s date. But, today when I run this program there was no internet connection in my computer …

Total answers: 2

How do I get monotonic time durations in python?

How do I get monotonic time durations in python? Question: I want to log how long something takes in real walltime. Currently I’m doing this: startTime = time.time() someSQLOrSomething() print “That took %.3f seconds” % (time.time() – startTime) But that will fail (produce incorrect results) if the time is adjusted while the SQL query (or …

Total answers: 5