mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
Merge pull request #127 from Ritu1611/patch-2
Probability Function for Sum on dice faces
This commit is contained in:
@@ -737,6 +737,27 @@ def hcfFunc(maxVal=20):
|
|||||||
solution = str(x)
|
solution = str(x)
|
||||||
return problem, solution
|
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 {} dice are rolled at the same time, the probability of getting a sum of {} =".format(a,b)
|
||||||
|
solution="{}/{}".format(count, 6**a)
|
||||||
|
return problem, solution
|
||||||
|
|
||||||
# || Class Instances
|
# || Class Instances
|
||||||
|
|
||||||
#Format is:
|
#Format is:
|
||||||
@@ -794,3 +815,4 @@ powerRuleIntegration = Generator("Power Rule Integration", 48, "nx^m=", "(n/m)x^
|
|||||||
fourthAngleOfQuadrilateral = Generator("Fourth Angle of Quadrilateral",49,"Fourth angle of Quadrilateral with angles a,b,c =","angle4",fourthAngleOfQuadriFunc)
|
fourthAngleOfQuadrilateral = Generator("Fourth Angle of Quadrilateral",49,"Fourth angle of Quadrilateral with angles a,b,c =","angle4",fourthAngleOfQuadriFunc)
|
||||||
quadraticEquationSolve = Generator("Quadratic Equation", 50, "Find the zeros {x1,x2} of the quadratic equation ax^2+bx+c=0", "x1,x2", quadraticEquation)
|
quadraticEquationSolve = Generator("Quadratic Equation", 50, "Find the zeros {x1,x2} of the quadratic equation ax^2+bx+c=0", "x1,x2", quadraticEquation)
|
||||||
hcf = Generator("HCF (Highest Common Factor)", 51, "HCF of a and b = ", "c", hcfFunc)
|
hcf = Generator("HCF (Highest Common Factor)", 51, "HCF of a and b = ", "c", hcfFunc)
|
||||||
|
DiceSumProbability=Generator("Probability of a certain sum appearing on faces of dice", 52,"If n dices are rolled then probabilty of getting sum of x is =","z", DiceSumProbFunc)
|
||||||
Reference in New Issue
Block a user