Guest User

Untitled

a guest
Jun 5th, 2023
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. def generate_numbers(n_min, n_max):
  2.     n_avg = (n_min + n_max) / 2
  3.     n_min_bound = 0.8 * n_avg
  4.     n_max_bound = 1.2 * n_avg
  5.  
  6.     while True:
  7.         num1 = random.uniform(n_min_bound, n_max_bound)
  8.         num2 = random.uniform(n_min_bound, n_max_bound)
  9.         avg = (num1 + num2) / 2
  10.  
  11.         if n_min <= avg <= n_max:
  12.             return num1, num2
  13.  
Advertisement
Add Comment
Please, Sign In to add comment