diff --git a/mathgenerator/_gen_list.py b/mathgenerator/_gen_list.py index 8d2b18a..4cca868 100644 --- a/mathgenerator/_gen_list.py +++ b/mathgenerator/_gen_list.py @@ -128,4 +128,5 @@ gen_list = [ ("simplify_square_root", "basic_math"), ("line_equation_from_2_points", "algebra"), ("orthogonal_projection", "algebra"), + ("area_of_trapezoid", "geometry"), ] diff --git a/mathgenerator/geometry.py b/mathgenerator/geometry.py index a68dd32..ad8c6ee 100644 --- a/mathgenerator/geometry.py +++ b/mathgenerator/geometry.py @@ -104,6 +104,24 @@ def area_of_circle_given_center_and_point(max_coordinate=10, max_radius=10): return problem, f'${area}$' +def area_of_trapezoid(max_len=20): + r"""Area of Trapezoid + + | Ex. Problem | Ex. Solution | + | --- | --- | + | Area of trapezoid with height $12$ and base lengths: $3, 7, = $ | $60$ | + """ + a = random.randint(1, max_len) + b = random.randint(1, max_len) + h = random.randint(1, max_len) + + area = (a + b) * h / 2 + + problem = f"Area of trapezoid with height ${h}$ and base lengths: ${a}, {b}, = $" + solution = f'${round(area, 2)}$' + return problem, solution + + def area_of_triangle(max_a=20, max_b=20): r"""Area of Triangle