mirror of
https://github.com/DeaDvey/mathgenerator.git
synced 2025-11-28 06:25:23 +01:00
19 lines
575 B
Python
19 lines
575 B
Python
from .__init__ import *
|
|
from ..__init__ import Generator
|
|
|
|
|
|
def pythagoreanTheoremFunc(maxLength=20):
|
|
a = random.randint(1, maxLength)
|
|
b = random.randint(1, maxLength)
|
|
c = (a**2 + b**2)**0.5
|
|
|
|
problem = f"The hypotenuse of a right triangle given the other two lengths {a} and {b} = "
|
|
solution = f"{c:.0f}" if c.is_integer() else f"{c:.2f}"
|
|
return problem, solution
|
|
|
|
|
|
pythagoreanTheorem = Generator(
|
|
"Pythagorean Theorem", 25,
|
|
"The hypotenuse of a right triangle given the other two lengths a and b = ",
|
|
"hypotenuse", pythagoreanTheoremFunc)
|