Permutation + Formula Execution - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Permutation + Formula Execution (/thread-23481.html) |
Permutation + Formula Execution - hds4ifc - Jan-01-2020 Q: Sum 50 balls in a box, 8= Blue, 13= Black, remaining= grey, I pick 5 balls randomly, pick another then put 1 back, pick another then put 1 back, i. Then return a ball & pick another different color, chance Blue & Black I. ≥ 2? II. ≥ whatever # within draw #? ii. After i. pick 1x randomly, then i. . This step's repeated an arbitrary # of times, I. ≥ 2? II. ≥ whatever # within draw #? Anyone know is possible in Python/ better in other language( s)? If yes pls tell me where learn the specific code for this? RE: Permutation + Formula Execution - Gribouillis - Jan-01-2020 What does I. ≥ 2? mean? Please explain the problem with complete sentences as it is currently more than obscure.
RE: Permutation + Formula Execution - sandeep_ganga - Jan-02-2020 Try below to see if that helps you, i added for finding chances of all picked are same color. import math #boxcount=int(input("number of boxes")) #1 totalobjects=int(input("count of objects")) #50 colorcount=int(input("no of colurs for objects in boxes")) #8-blue,13-black,29-grey #name and count i=0 x=[] y=[] while i < colorcount: xn, yn=input("count of objects seperated by color name: ").split() x.append(xn) y.append(yn) i+=1 x=list(map(int,x)) y = [element.upper() for element in y] print(x,y) #counts of obj of each colors xindex=0 yindex=0 pick=int(input("objects picked: ")) wantedcolor=input("function find chances of all to be --> , name the color search: ") yindex=y.index(wantedcolor.upper()) xindex=yindex #q1---->pick=5 chance of all blue ==> 8c5/50c5,,, print(x[xindex]) num=x[xindex]-pick print(num) print(totalobjects) den=totalobjects-pick print(den) if sum(x)==totalobjects: print("chances are : ",(math.factorial(x[xindex])/math.factorial(num))/(math.factorial(totalobjects)/math.factorial(den))) print( "----------------") Best Regards,Sandeep GANGA SANDEEP KUMAR |