import random tryes = 0 true = 0 allattempts = 0 attempts = 0 same = int(input("Количество чисел подряд ")) // number of numbers in a row required ex 2 mnum = int(input("Введите радиус ")) // radius (1-number) ex 2 repeats = int(input("Введите количество повторов (чем больше тем точнее) ")) // number of retries for better accuracy number = random.randint(1, mnum) while tryes < repeats : copy = number print(copy) number = random.randint(1, mnum) print(number) attempts = attempts + 1 if number == copy : true = true + 1 if copy != number : true = 0 if true == same-1 : attempts = attempts - (same - 1) allattempts = allattempts + attempts attempts = 0 tryes = tryes + 1 true = 0 print(str(tryes) + "/" + str(repeats)) -print(str(100/allattempts) + "%") -input()**Console log**
1
2
2
2
1/10
2
2
2/10
2
1
1
2
2
2
3/10
2
1
1
1
4/10
1
2
2
1
1
1
5/10
1
2
2
1
1
1
6/10
1
2
2
1
1
1
7/10
1
2
2
2
8/10
2
2
9/10
2
2
10/10
9.090909090909092%