Advertisement
pacho_the_python

botche

Jan 26th, 2023
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. import random
  2. import time
  3.  
  4.  
  5. def create_list_in_range(min_value, max_value):
  6.     random_list = [x for x in range(min_value, max_value)]
  7.     return random_list
  8.  
  9.  
  10. def get_random_element_from_list(some_list):
  11.     result = random.choice(some_list)
  12.     return result
  13.  
  14.  
  15. def count_down_hello(min_num, max_num, number_of_iterations):
  16.     counter = 0
  17.     while True:
  18.         counter += 1
  19.         generated_list = create_list_in_range(min_num, max_num)
  20.         counter_sec = get_random_element_from_list(generated_list)
  21.         tic = time.perf_counter()
  22.         while True:
  23.             toc = time.perf_counter()
  24.             if toc - tic > 1:
  25.                 counter_sec -= 1
  26.                 print(counter_sec)
  27.                 tic = toc
  28.                 if counter_sec == 0:
  29.                     print("Hello!")
  30.                     break
  31.         if counter == number_of_iterations:
  32.             break
  33.  
  34.  
  35. count_down_hello(5, 20, 5)
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement