@@ -765,6 +765,12 @@ def trapezoid(a: any, b: any, c: any = None, d: any = None, h: any = None, retur
765
765
raise MathTypeError ("a must be a number" )
766
766
if not isinstance (b , (int , float )):
767
767
raise MathTypeError ("b must be a number" )
768
+ if return_area or return_both and not isinstance (h , (int , float )):
769
+ raise MathTypeError ("h must be a number" )
770
+ if return_circumference or return_both and not isinstance (c , (int , float )):
771
+ raise MathTypeError ("c must be a number" )
772
+ if return_circumference or return_both and not isinstance (d , (int , float )):
773
+ raise MathTypeError ("d must be a number" )
768
774
if return_area or return_both and isinstance (h , int ):
769
775
h = float (h )
770
776
if return_circumference or return_both and isinstance (c , int ):
@@ -801,6 +807,68 @@ def trapezoid(a: any, b: any, c: any = None, d: any = None, h: any = None, retur
801
807
elif return_circumference :
802
808
return _circumference
803
809
810
+ @staticmethod
811
+ def parallelogram (a : any , b : any = None , h : any = None , return_area : bool = False , return_circumference : bool = False , return_both : bool = True , return_int : bool = False , return_string : bool = False ):
812
+ """
813
+ Calculate the Area or the Circumference of a Parallelogram.
814
+ """
815
+ from .highpymath import parallelogram_area as _pa
816
+ from .highpymath import parallelogram_circumference as _pc
817
+ if not return_area and not return_circumference and not return_both :
818
+ raise MathValueError ("You need to specify one of the 3 arguments" )
819
+ if return_area and return_circumference :
820
+ raise MathValueError ("You need to specify one of the 3 arguments" )
821
+ if return_area and return_both :
822
+ return_both = False
823
+ if return_circumference and return_both :
824
+ return_both = False
825
+ return_float = True
826
+ if return_int :
827
+ return_float = False
828
+ if return_area and h is None :
829
+ raise MathValueError ("You need to specify h" )
830
+ if return_circumference or return_both and b is None :
831
+ raise MathValueError ("You need to specify b" )
832
+ if not isinstance (a , (int , float )):
833
+ raise MathTypeError ("a must be a number" )
834
+ if return_area or return_both and not isinstance (h , (int , float )):
835
+ raise MathTypeError ("h must be a number" )
836
+ if return_circumference or return_both and not isinstance (b , (int , float )):
837
+ raise MathTypeError ("b must be a number" )
838
+ if isinstance (a , int ):
839
+ a = float (a )
840
+ if isinstance (b , int ):
841
+ b = float (b )
842
+ if return_area and isinstance (h , int ):
843
+ h = float (h )
844
+ if return_circumference and isinstance (b , int ):
845
+ b = float (b )
846
+ if return_area or return_both :
847
+ _area = _pa (a = a , h = h )
848
+ if return_circumference or return_both :
849
+ _circumference = _pc (a = a , b = b )
850
+ if return_int :
851
+ if _area :
852
+ _area = int (_area )
853
+ if _circumference :
854
+ _circumference = int (_circumference )
855
+ elif return_float :
856
+ if _area :
857
+ _area = float (_area )
858
+ if _circumference :
859
+ _circumference = float (_circumference )
860
+ if return_string :
861
+ if _area :
862
+ _area = str (_area )
863
+ if _circumference :
864
+ _circumference = str (_circumference )
865
+ if return_both :
866
+ return _area , _circumference
867
+ elif return_area :
868
+ return _area
869
+ elif return_circumference :
870
+ return _circumference
871
+
804
872
GeometricProperties2D = GeometricProperties2D ()
805
873
806
874
__all__ .append ('GeometricProperties2D' )
0 commit comments