Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def generate_numbers(n_min, n_max):
- n_avg = (n_min + n_max) / 2
- n_min_bound = 0.8 * n_avg
- n_max_bound = 1.2 * n_avg
- while True:
- num1 = random.uniform(n_min_bound, n_max_bound)
- num2 = random.uniform(n_min_bound, n_max_bound)
- avg = (num1 + num2) / 2
- if n_min <= avg <= n_max:
- return num1, num2
Advertisement
Add Comment
Please, Sign In to add comment