From dedbb7027e1f53cad75608991fdd6d50de75589d Mon Sep 17 00:00:00 2001 From: Ritu Raj <68614399+Ritu1611@users.noreply.github.com> Date: Sat, 17 Oct 2020 11:47:30 +0530 Subject: [PATCH 1/2] Probability Function for Sum on dice faces --- mathgenerator/mathgen.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 1041a55..866a2f2 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -714,6 +714,27 @@ def fourthAngleOfQuadriFunc(maxAngle = 180): solution = angle4 return problem, solution +def DiceSumProbFunc(maxDice=3): + a = random.randint(1,maxDice) + b = random.randint(a,6*a) + count=0 + for i in [1,2,3,4,5,6]: + if a==1: + if i==b: + count=count+1 + elif a==2: + for j in [1,2,3,4,5,6]: + if i+j==b: + count=count+1 + elif a==3: + for j in [1,2,3,4,5,6]: + for k in [1,2,3,4,5,6]: + if i+j+k==b: + count=count+1 + problem = "If {} dices rolled at the same time, Probability of getting a sum of {} =".format(a,b) + solution="{}/{}".format(count, 6**a) + return problem, solution + # || Class Instances #Format is: @@ -769,3 +790,4 @@ matrixMultiplication = Generator("Multiplication of two matrices", 46, "Multipl CubeRoot = Generator("Cube Root",47,"Cuberoot of a upto 2 decimal places is","b",cubeRootFunc) powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=", "(n/m)x^(m+1)", powerRuleIntegrationFunc) fourthAngleOfQuadrilateral = Generator("Fourth Angle of Quadrilateral",49,"Fourth angle of Quadrilateral with angles a,b,c =","angle4",fourthAngleOfQuadriFunc) +DiceSumProbability=Generator("Probability of a certain sum appearing on faces of dice",50,"If n dices are rolled then probabilty of getting sum of x is", DiceSumProbFunc) From e3834b2c8951be2670dc6a8a3ea64c7eca81725a Mon Sep 17 00:00:00 2001 From: Ritu Raj <68614399+Ritu1611@users.noreply.github.com> Date: Sat, 17 Oct 2020 11:54:50 +0530 Subject: [PATCH 2/2] Update mathgen.py --- mathgenerator/mathgen.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 866a2f2..a5164a1 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -790,4 +790,4 @@ matrixMultiplication = Generator("Multiplication of two matrices", 46, "Multipl CubeRoot = Generator("Cube Root",47,"Cuberoot of a upto 2 decimal places is","b",cubeRootFunc) powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=", "(n/m)x^(m+1)", powerRuleIntegrationFunc) fourthAngleOfQuadrilateral = Generator("Fourth Angle of Quadrilateral",49,"Fourth angle of Quadrilateral with angles a,b,c =","angle4",fourthAngleOfQuadriFunc) -DiceSumProbability=Generator("Probability of a certain sum appearing on faces of dice",50,"If n dices are rolled then probabilty of getting sum of x is", DiceSumProbFunc) +DiceSumProbability=Generator("Probability of a certain sum appearing on faces of dice",50,"If n dices are rolled then probabilty of getting sum of x is =","z", DiceSumProbFunc)