C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

C++

how to use delay of time in c++ or python

22nd May 2018, 6:54 AM
Jamaluddin Huseinkhail
Jamaluddin Huseinkhail - avatar
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.
22nd May 2018, 7:18 PM
Timon Paßlick
+ 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
22nd May 2018, 7:24 AM
Koketso Dithipe
Koketso Dithipe - avatar
+ 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
22nd May 2018, 7:31 PM
Koketso Dithipe
Koketso Dithipe - avatar
+ 3
In c++ you can use _sleep(milliseconds) in <stdlib>.
22nd May 2018, 7:04 AM
XiLef
+ 3
Black Hat Click the link, there's a sample code.
22nd May 2018, 7:11 PM
Timon Paßlick
22nd May 2018, 1:51 PM
Timon Paßlick
+ 2
thanks all friends
22nd May 2018, 11:11 PM
Jamaluddin Huseinkhail
Jamaluddin Huseinkhail - avatar
0
print the cod of it pls
22nd May 2018, 7:10 PM
Jamaluddin Huseinkhail
Jamaluddin Huseinkhail - avatar
0
i clicked but it was not simple for beginners ...
22nd May 2018, 7:13 PM
Jamaluddin Huseinkhail
Jamaluddin Huseinkhail - avatar