What do you want to save?
Add Code snippet
New code examples
-
Python 2021-10-10 08:22:04
python version of settimout
from datetime import datetime, timedelta import heapq # just holds a function, its arguments, and when we want it to execute. class TimeoutFunction: def __init__(self, function, timeout, *args): self.function = function self.args = ar... Add solution -
Python 2021-10-08 14:11:07
formatting time in python
The program below converts a datetime object containing current date and time to different string formats. Code: from datetime import datetime now = datetime.now() # current date and time year = now.strftime("%Y") print("year:", ... Add solution -
Python 2021-10-03 06:37:02
how to make a set of math questions in python
import random from datetime import datetime import time random.seed(time.time()) answerlist=[] for i in range(1,26): sw = False f = random.randint(1,99) w = random.randint(1,99) if f >= 10 and w >= 10: sw = True while sw == False: ... Add solution -
Python 2021-10-03 06:02:07
python datetime round to nearest hour
from datetime import datetime, timedelta now = datetime.now() def hour_rounder(t): # Rounds to nearest hour by adding a timedelta hour if minute >= 30 return (t.replace(second=0, microsecond=0, minute=0, hour=t.hour) +timedelta... Add solution