Merge branch 'master' into nella17-patch

This commit is contained in:
Luke Weiler
2020-10-26 13:21:08 -04:00
committed by GitHub
7 changed files with 193 additions and 112 deletions

View File

@@ -110,5 +110,8 @@ from .minutes_to_hours import *
from .decimal_to_bcd import *
from .circumference import *
from .combine_like_terms import *
from .signum_function import *
from .conditional_probability import *
from .arc_length import *
from .binomial_distribution import *
from .stationary_points import *

View File

@@ -0,0 +1,15 @@
from .__init__ import *
def arclengthFunc(maxRadius=49, maxAngle=359):
Radius = random.randint(1, maxRadius)
Angle = random.randint(1, maxAngle)
problem = f"Given radius, {Radius} and angle, {Angle}. Find the arc length of the angle."
angle_arc_length = float((Angle / 360) * 2 * math.pi * Radius)
formatted_float = "{:.5f}".format(angle_arc_length)
solution = f"Arc length of the angle = {formatted_float}"
return problem, solution
arc_length = Generator("Arc length of Angle", 108,
" Given the radius, r and angle, ang. Calculate the arc length of the given angle", "(ang/360) * 2 * pi * r", arclengthFunc)

View File

@@ -0,0 +1,42 @@
from .__init__ import *
def factorial(n):
if n == 1 or n == 0:
return 1
else:
return n * factorial(n - 1)
def newton_symbol(n, k):
return factorial(n) / (factorial(k) * factorial(n - k))
def binomialDistFunc():
rejected_fraction = float(random.randint(30, 40)) + random.random()
batch = random.randint(10, 20)
rejections = random.randint(1, 9)
answer = 0
rejected_fraction = round(rejected_fraction, 2)
problem = "A manufacturer of metal pistons finds that, on average, {0:}% "\
"of the pistons they manufacture are rejected because " \
"they are incorrectly sized. What is the probability that a "\
"batch of {1:} pistons will contain no more than {2:} " \
"rejected pistons?".format(rejected_fraction, batch, rejections)
for i in range(0, rejections + 1):
answer += newton_symbol(float(batch), float(i)) * ((rejected_fraction / 100.) ** float(i)) * \
((1 - (rejected_fraction / 100.)) ** (float(batch) - float(i)))
answer = round(100 * answer, 2)
return problem, answer
binomial_distribution = Generator("Binomial distribution", 109,
"P(X<x)=", "c", binomialDistFunc)

View File

@@ -24,4 +24,4 @@ def conditionalProbFunc():
conditional_probability = Generator("Conditional Probability",
105, "P(A|+)=", "c", conditionalProbFunc)
107, "P(A|+)=", "c", conditionalProbFunc)

View File

@@ -0,0 +1,19 @@
from .__init__ import *
import random
def signumFunc(min=-999, max=999):
a = random.randint(min, max)
b = 0
if (a > 0):
b = 1
if (a < 0):
b = -1
problem = "signum of " + str(a) + " is " + "="
solution = str(b)
return problem, solution
signum_function = Generator("signum function", 106,
"signum function of a is", "b",
signumFunc)