Here is another quick tip about a new function called time.sleep().
I'm not sure yet if this is the only function for time, but it is an important function for time.
Now, in order to use time, you have to type:
import time
But, we might want to do this in a New Window, not IDLE. Type "import time" in a New Window (I bet I got you there, didn't I?). Now, type the following:
time.sleep(4)
print("Hi.")
Now, run the program. At first, you won't get anything... But, then, "Hi." finally appears. How did that happen? Time.sleep() actually pauses the program for the amount of seconds in the parenthesis (()).
I guess that's all we had to talk about here. I challenge you to try to write a countdown program (hint: you will need to use a for loop)! You don't have to make the program ask the user how many seconds and/or what kind of time they want (seconds, minutes, or hours), but you can try!
No comments:
Post a Comment