Python while sampling

0 votes

I'm searching to make a loop to go throw samples till I reach the result. Example:

    i=(list(np.random.randint(2, size=5)),list(np.random.randint(2,  size=2)),list(np.random.randint(2, size=7)),list(np.random.randint(2, size=7)),list(np.random.randint(2, size=9)),list(np.random.randint(2, size=8)),list(np.random.randint(2, size=7)))

    for j in range(0,len(anytable)):
        if resp(i,(anytable.iloc[j,0:7].tolist())):  #this function "resp"  gives me True and False and add 1 to variable "tot"

Now I want to stop till I have to tot>=100 . So I have to generate many "i" samples lists till I get to tot>=100.

How can I do this?

Thank you very much

Sep 10, 2018 in Python by bug_seeker
• 14,960 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

From guessing I would say, this could be your solution.

j, tot = 1, 1
while j<len(anytable) and tot<100 :
    tot += int( resp(i,(anytable.iloc[j,0:7].tolist())) )
    j   += 1

The condition is false if one of the inequations is false. The incementing operator += on tot is adding the integer representation of a boolean True = 1 or False = 0 to the value of tot.

answered Sep 10, 2018 by Priyaj
• 56,100 points

Related Questions In Python

+2 votes
2 answers

Error while printing hello world in python.

You must be trying this command in ...READ MORE

answered Mar 31, 2018 in Python by GandalfDwhite
• 1,320 points
0 votes
1 answer

Do-while loop in Python

Python does not have a do-while construct.  If ...READ MORE

answered May 11, 2018 in Python by Hamartia's Mask
• 1,580 points
0 votes
1 answer

Empty while loop in Python

while file.readline().startswith("#"):     pass The pass statement does nothing. It ...READ MORE

answered Dec 5, 2018 in Python by SDeb
• 9,300 points
0 votes
1 answer

Python UnboundLocalError error while executing script

The reason for this error is that ...READ MORE

answered Jan 22 in Python by Omkar
• 65,810 points
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 920 points
0 votes
1 answer

Python while sampling

I would say, this could be your ...READ MORE

answered Sep 20, 2018 in Python by Priyaj
• 56,100 points
0 votes
1 answer

Why there is no do while loop in python

There is no do...while loop because there ...READ MORE

answered Aug 6, 2018 in Python by Priyaj
• 56,100 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.