-
-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Included area of n sided regular polygon #7438
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Added a function to calculate the area of n sided regular polygons
for more information, see https://pre-commit.ci
@@ -458,6 +458,49 @@ def area_rhombus(diagonal_1: float, diagonal_2: float) -> float: | |||
return 1 / 2 * diagonal_1 * diagonal_2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps add some doctests here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there! doctests were already present in there. I wonder if that's a mistake.
print(f"Cone: {surface_area_cone(10, 20) = }") | ||
print(f"Conical Frustum: {surface_area_conical_frustum(10, 20, 30) = }") | ||
print(f"Cylinder: {surface_area_cylinder(10, 20) = }") | ||
print(f"Equilateral Triangle: {area_reg_polygon(3, 10) = }") | ||
print(f"Square: {area_reg_polygon(4, 10) = }") | ||
print(f"Reqular Pentagon: {area_reg_polygon(5, 10) = }") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need them since you already used doctest to test your code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ZeroDayOwl , Based on the format of preexisting functions, I doubt if I'm allowed to proceed with your suggestion.
"area_reg_polygon() only accepts non-negative values as \ | ||
length of a side" | ||
) | ||
return (sides * length**2) / (4 * tan(pi / sides)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (sides * length**2) / (4 * tan(pi / sides)) | |
return (sides * pow(length, 2)) / (4 * tan(pi / sides)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @CaedenPH , Based on the format of preexisting functions, I doubt if I'm allowed to commit your suggestion.
Added a function to calculate the area of n sided regular polygons
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.