Advertisement
FranzVuttke

gen_seq

Jan 10th, 2023 (edited)
117
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. import random
  2. def gen_seq():
  3.     a, b, c = 0, 0, 0
  4.     while True:
  5.         a = random.randint(1, 100)
  6.         b = random.randint(1, 100)
  7.         c = random.randint(1, 100)
  8.         if a < b and b < c:
  9.             if b-a == c-b:
  10.                 return [(a, b, c), b-a]
  11.  
  12. for _ in range(10):
  13.     print(gen_seq())
  14.  
Advertisement
Comments
  • FranzVuttke
    2 years
    # text 0.21 KB | 0 0
    1. #Program ma wylosować trzy liczby całkowite do zmiennych a, b oraz c z przedziału <-20, 200>.
    2. #Losowanie trwa do momentu w którym zmienne a, b, c w podanej kolejności tworzą ciąg rosnący arytmetyczny.
Add Comment
Please, Sign In to add comment
Advertisement