H
H
haniaman2020-06-10 21:24:12
Python
haniaman, 2020-06-10 21:24:12

How can I make sure that if the numbers in the interval were in the tuple a certain number of times, the condition is fulfilled?

Hello, there is a tuple with numbers

count = (5.60, 1.44, 1.32, 4.90, 2.97, 4.37, 7.18, 1.52, 1.20, 1.48, 1.45, 1.23, 3.58, 1.16, 0, 3.20, 3.36, 3.06, 12.78,
1.16, 1.17, 1.06, 1.23, 2.04, 5.21, 1.00, 1.32, 1.05, 5.33, 1.08, 4.29, 3.14, 1.04, 0, 1.22, 1.44, 1.00, 0, 1.55, 2.35,
1.98, 2.07, 1.82, 1.34, 4.12, 5.64, 1.16, 2.63, 1.97, 1.66, 2.70, 1.09, 24.37, 2.73, 1.30, 1.41, 1,103.24, 1.25, 0,
16.82, 1.03, 0, 1.20 ... )


I access numbers in the following way:
number = 1 # number for tuple
while True:
    if count[number] == 1.32:
        print('Игра 1.32 нашлась на месте ' + str(number))
        break
    else:
        number += 1

I define the gap like this:
kf_waits_ot =  1.32 # начало промужутка кф, от
kf_waits_do =  10  # окончание промежутка кф, до

It is necessary to make, for example, in the interval 1.30 - 5.00 the numbers were 3 times in a row, then this and that will be
done And I got something like this:
kf_waits_ot =  1.32 # начало промужутка кф, от
kf_waits_do =   1.45 # окончание промежутка кф, до
number_kf_waits = 2 # кол-во раз сколько числа из промежутка должны выпасть

while True:
  if count[number] >= kf_waits_ot and count[number] <= kf_waits_do:
    if number_kf_waits != number:
      number += 1
      print('False')
    else:
      print('True, bet allow')
      break
  else:
    number += 1
    print('Число не подходит в промежуток, следующее...')

This script somehow worked and found the interval, but if I enter larger numbers or longer intervals, then something strange happens and, according to the results of the script, I cannot find the interval that was considered correct.

Please help :)

Ps I didn’t even understand why the number of numbers in the interval should not be equal to the number for the tuple

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-06-10
@haniaman

kf_waits_ot =  1.32
kf_waits_do =   1.45
number_kf_waits = 2


numbers_in_row = 0
for number in count:
    
    if number >= kf_waits_ot and number <= kf_waits_do:
        numbers_in_row += 1
    else:
        numbers_in_row = 0
    
    if numbers_in_row == number_kf_waits:
        print('++')
        break

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question