New course! Every coder should learn Generative AI!
Try a free lesson0
C++
how to use delay of time in c++ or python
9 Answers
+ 3
You include <thread> and <chrono>.
Then you call
std::this_thread::sleep_for(/*your duration*/);
Your duration could be 2s or 100ms.
+ 9
In python, you have to import the time module then use this function in your code:
time.sleep(secs)
secs specifies the amount of seconds the program should pause. This can be an integer or a float
+ 8
This is a countdown timer in python, the program pauses for 1 second each time before executing. I tried running it on Code Playground and got a time limit exceeded error; the code does work on IDLE and Termux though though:
import time
def countdown(x):
while x>0:
print(x)
x-=1
time.sleep(1)
if x==0:
print("Timeout")
countdown(60)
https://code.sololearn.com/cK8q7Yah3e2l/?ref=app
+ 3
In c++ you can use _sleep(milliseconds) in <stdlib>.
+ 3
Black Hat Click the link, there's a sample code.
+ 2
thanks all friends
0
print the cod of it pls
0
i clicked but it was not simple for beginners ...