python - Comparing values in range -


have 2 variables 'wins' , 'clicks' values ranging 1 100k each.

need flag when 'wins' in multiples of 150, , when 'clicks' 0 or 1?

requirement: iteratively want increment both values

 if 150<=int(wins)<=300 , 0<=int(clicks)<=1: 

need flag when "wins in multiples of 150" , when "clicks 0 or 1"

try

flag = (clicks in (0, 1) , (wins % 150) == 0) 
  • clicks in (0, 1): means clicks either 0 or 1
  • (wins % 150) == 0: means wins % 150 remainder zero, win divisible 150.

check following:

>>> clicks, wins = 0, 150 * 7 >>> flag = (clicks in (0, 1) , (wins % 150) == 0) >>> flag true >>> clicks, wins = 2, 150 * 7 >>> flag = (clicks in (0, 1) , (wins % 150) == 0) >>> flag false >>>  

note: if 'clicks' , 'winds' strings, need use typecase int(clicks), int(wins). in answer both winds , clicks int.


edit: tried make sense of comments , question. may above answer following you:

comment-1: data type int wins , clicks:

if wins , clicks int values don't need use typecase. doing above in answer.

comment-2: want retrieve records 150 wins , clicks = 0:

implementing logic simple:

if winds == 150 , clicks == 0:   # code retrieve record   

last:

comment-3: increment wins counter in multiples 150 (should retrieve records when wins in between 150-300 , clicks = 0)
4) while incrementing wins counter need increment clicks counter retrieve records

e.g. when wins=[300-450] , clicks=1 retreive,
wins=[300-450] , clicks = 2 skip

hard understand! still believe need like:

# `num` until wants execute  _ in range(0, num):   if clicks in (0, 1) , (wins % 150) == 0:      # code retrieve record   wins += 150        

i don't know why increments clicks, if wants retrieve records clicks value 0, 1.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -