Advertisement
Guest User

Untitled

a guest
Jan 29th, 2020
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import threading
  2. # Imports the module needed for this code.
  3.  
  4. print("Start waiting!")
  5. # Prints a message saying it's started waiting.
  6.  
  7. def my_function():
  8. # Defines a function called "my_function" This function can be called at any time by writing "my_function()".
  9. # A function is a piece of code you can create once, and then refer back to later. It's useful if you use the same code over and over again.
  10. # Function names should always be lowercase, with underscores as spaces.
  11.  
  12. print("I just waited 5 seconds!")
  13. # Prints the message saying it's waited the 5 seconds.
  14.  
  15. timer = threading.Timer(5, my_function)
  16. # Creates a variable to hold the timer.
  17. # In the above line, the 5 is how many seconds the timer should run for.
  18. # The "my_function" is the function (see above) to run after the 5 seconds (or however long you set the seconds to).
  19.  
  20. timer.start()
  21. # Starts the countdown using the information from line 11. If you changed the variable name, you need to change it here too.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement