开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
开源项目 > 程序开发 > 算法/数学计算 &&
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
96 Star 718 Fork 324

编程语言算法集/Python

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (99)
master
dependabot/uv/lxml-6.1.0
pre-commit-ci-update-config
copilot/fix-test-failures-and-mypy-issues
dependabot/github_actions/actions/checkout-6
pytest-run-parallel
delete-requirements.txt
Python-3.14
uv-again
Sphinx-runs-on-ubuntu-24.04-arm
dependabot/github_actions/astral-sh/setup-uv-5
Shebang-python-for-Windows
gh-pages
Test-on-Python-3.13-beta
cclauss-patch-2
Keep-GitHub-Actions-up-to-date-with-Dependabot
Fewer-forward-propogations-to-speed-tests
cclauss-patch-1
Add-dataclasses-to-binary_search_tree.py
Simplify-is_bst.py
master
分支 (99)
master
dependabot/uv/lxml-6.1.0
pre-commit-ci-update-config
copilot/fix-test-failures-and-mypy-issues
dependabot/github_actions/actions/checkout-6
pytest-run-parallel
delete-requirements.txt
Python-3.14
uv-again
Sphinx-runs-on-ubuntu-24.04-arm
dependabot/github_actions/astral-sh/setup-uv-5
Shebang-python-for-Windows
gh-pages
Test-on-Python-3.13-beta
cclauss-patch-2
Keep-GitHub-Actions-up-to-date-with-Dependabot
Fewer-forward-propogations-to-speed-tests
cclauss-patch-1
Add-dataclasses-to-binary_search_tree.py
Simplify-is_bst.py
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (99)
master
dependabot/uv/lxml-6.1.0
pre-commit-ci-update-config
copilot/fix-test-failures-and-mypy-issues
dependabot/github_actions/actions/checkout-6
pytest-run-parallel
delete-requirements.txt
Python-3.14
uv-again
Sphinx-runs-on-ubuntu-24.04-arm
dependabot/github_actions/astral-sh/setup-uv-5
Shebang-python-for-Windows
gh-pages
Test-on-Python-3.13-beta
cclauss-patch-2
Keep-GitHub-Actions-up-to-date-with-Dependabot
Fewer-forward-propogations-to-speed-tests
cclauss-patch-1
Add-dataclasses-to-binary_search_tree.py
Simplify-is_bst.py
Python
/
maths
/
volume.py
Python
/
maths
/
volume.py
volume.py 18.01 KB
一键复制 编辑 原始数据 按行查看 历史
Omkaar 提交于 2025年10月16日 01:35 +08:00 . Fix a few typos (#13346)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567
"""
Find the volume of various shapes.
* https://en.wikipedia.org/wiki/Volume
* https://en.wikipedia.org/wiki/Spherical_cap
"""
from __future__ import annotations
from math import pi, pow # noqa: A004
def vol_cube(side_length: float) -> float:
"""
Calculate the Volume of a Cube.
>>> vol_cube(1)
1.0
>>> vol_cube(3)
27.0
>>> vol_cube(0)
0.0
>>> vol_cube(1.6)
4.096000000000001
>>> vol_cube(-1)
Traceback (most recent call last):
...
ValueError: vol_cube() only accepts non-negative values
"""
if side_length < 0:
raise ValueError("vol_cube() only accepts non-negative values")
return pow(side_length, 3)
def vol_spherical_cap(height: float, radius: float) -> float:
"""
Calculate the volume of the spherical cap.
>>> vol_spherical_cap(1, 2)
5.235987755982988
>>> vol_spherical_cap(1.6, 2.6)
16.621119532592402
>>> vol_spherical_cap(0, 0)
0.0
>>> vol_spherical_cap(-1, 2)
Traceback (most recent call last):
...
ValueError: vol_spherical_cap() only accepts non-negative values
>>> vol_spherical_cap(1, -2)
Traceback (most recent call last):
...
ValueError: vol_spherical_cap() only accepts non-negative values
"""
if height < 0 or radius < 0:
raise ValueError("vol_spherical_cap() only accepts non-negative values")
# Volume is 1/3 pi * height squared * (3 * radius - height)
return 1 / 3 * pi * pow(height, 2) * (3 * radius - height)
def vol_spheres_intersect(
radius_1: float, radius_2: float, centers_distance: float
) -> float:
r"""
Calculate the volume of the intersection of two spheres.
The intersection is composed by two spherical caps and therefore its volume is the
sum of the volumes of the spherical caps.
First, it calculates the heights :math:`(h_1, h_2)` of the spherical caps,
then the two volumes and it returns the sum.
The height formulas are
.. math::
h_1 = \frac{(radius_1 - radius_2 + centers\_distance)
\cdot (radius_1 + radius_2 - centers\_distance)}
{2 \cdot centers\_distance}
h_2 = \frac{(radius_2 - radius_1 + centers\_distance)
\cdot (radius_2 + radius_1 - centers\_distance)}
{2 \cdot centers\_distance}
if `centers_distance` is 0 then it returns the volume of the smallers sphere
:return: ``vol_spherical_cap`` (:math:`h_1`, :math:`radius_2`)
+ ``vol_spherical_cap`` (:math:`h_2`, :math:`radius_1`)
>>> vol_spheres_intersect(2, 2, 1)
21.205750411731103
>>> vol_spheres_intersect(2.6, 2.6, 1.6)
40.71504079052372
>>> vol_spheres_intersect(0, 0, 0)
0.0
>>> vol_spheres_intersect(-2, 2, 1)
Traceback (most recent call last):
...
ValueError: vol_spheres_intersect() only accepts non-negative values
>>> vol_spheres_intersect(2, -2, 1)
Traceback (most recent call last):
...
ValueError: vol_spheres_intersect() only accepts non-negative values
>>> vol_spheres_intersect(2, 2, -1)
Traceback (most recent call last):
...
ValueError: vol_spheres_intersect() only accepts non-negative values
"""
if radius_1 < 0 or radius_2 < 0 or centers_distance < 0:
raise ValueError("vol_spheres_intersect() only accepts non-negative values")
if centers_distance == 0:
return vol_sphere(min(radius_1, radius_2))
h1 = (
(radius_1 - radius_2 + centers_distance)
* (radius_1 + radius_2 - centers_distance)
/ (2 * centers_distance)
)
h2 = (
(radius_2 - radius_1 + centers_distance)
* (radius_2 + radius_1 - centers_distance)
/ (2 * centers_distance)
)
return vol_spherical_cap(h1, radius_2) + vol_spherical_cap(h2, radius_1)
def vol_spheres_union(
radius_1: float, radius_2: float, centers_distance: float
) -> float:
r"""
Calculate the volume of the union of two spheres that possibly intersect.
It is the sum of sphere :math:`A` and sphere :math:`B` minus their intersection.
First, it calculates the volumes :math:`(v_1, v_2)` of the spheres,
then the volume of the intersection :math:`i` and
it returns the sum :math:`v_1 + v_2 - i`.
If `centers_distance` is 0 then it returns the volume of the larger sphere
:return: ``vol_sphere`` (:math:`radius_1`) + ``vol_sphere`` (:math:`radius_2`)
- ``vol_spheres_intersect``
(:math:`radius_1`, :math:`radius_2`, :math:`centers\_distance`)
>>> vol_spheres_union(2, 2, 1)
45.814892864851146
>>> vol_spheres_union(1.56, 2.2, 1.4)
48.77802773671288
>>> vol_spheres_union(0, 2, 1)
Traceback (most recent call last):
...
ValueError: vol_spheres_union() only accepts non-negative values, non-zero radius
>>> vol_spheres_union('1.56', '2.2', '1.4')
Traceback (most recent call last):
...
TypeError: '<=' not supported between instances of 'str' and 'int'
>>> vol_spheres_union(1, None, 1)
Traceback (most recent call last):
...
TypeError: '<=' not supported between instances of 'NoneType' and 'int'
"""
if radius_1 <= 0 or radius_2 <= 0 or centers_distance < 0:
raise ValueError(
"vol_spheres_union() only accepts non-negative values, non-zero radius"
)
if centers_distance == 0:
return vol_sphere(max(radius_1, radius_2))
return (
vol_sphere(radius_1)
+ vol_sphere(radius_2)
- vol_spheres_intersect(radius_1, radius_2, centers_distance)
)
def vol_cuboid(width: float, height: float, length: float) -> float:
"""
Calculate the Volume of a Cuboid.
:return: multiple of `width`, `length` and `height`
>>> vol_cuboid(1, 1, 1)
1.0
>>> vol_cuboid(1, 2, 3)
6.0
>>> vol_cuboid(1.6, 2.6, 3.6)
14.976
>>> vol_cuboid(0, 0, 0)
0.0
>>> vol_cuboid(-1, 2, 3)
Traceback (most recent call last):
...
ValueError: vol_cuboid() only accepts non-negative values
>>> vol_cuboid(1, -2, 3)
Traceback (most recent call last):
...
ValueError: vol_cuboid() only accepts non-negative values
>>> vol_cuboid(1, 2, -3)
Traceback (most recent call last):
...
ValueError: vol_cuboid() only accepts non-negative values
"""
if width < 0 or height < 0 or length < 0:
raise ValueError("vol_cuboid() only accepts non-negative values")
return float(width * height * length)
def vol_cone(area_of_base: float, height: float) -> float:
r"""
| Calculate the Volume of a Cone.
| Wikipedia reference: https://en.wikipedia.org/wiki/Cone
:return: :math:`\frac{1}{3} \cdot area\_of\_base \cdot height`
>>> vol_cone(10, 3)
10.0
>>> vol_cone(1, 1)
0.3333333333333333
>>> vol_cone(1.6, 1.6)
0.8533333333333335
>>> vol_cone(0, 0)
0.0
>>> vol_cone(-1, 1)
Traceback (most recent call last):
...
ValueError: vol_cone() only accepts non-negative values
>>> vol_cone(1, -1)
Traceback (most recent call last):
...
ValueError: vol_cone() only accepts non-negative values
"""
if height < 0 or area_of_base < 0:
raise ValueError("vol_cone() only accepts non-negative values")
return area_of_base * height / 3.0
def vol_right_circ_cone(radius: float, height: float) -> float:
r"""
| Calculate the Volume of a Right Circular Cone.
| Wikipedia reference: https://en.wikipedia.org/wiki/Cone
:return: :math:`\frac{1}{3} \cdot \pi \cdot radius^2 \cdot height`
>>> vol_right_circ_cone(2, 3)
12.566370614359172
>>> vol_right_circ_cone(0, 0)
0.0
>>> vol_right_circ_cone(1.6, 1.6)
4.289321169701265
>>> vol_right_circ_cone(-1, 1)
Traceback (most recent call last):
...
ValueError: vol_right_circ_cone() only accepts non-negative values
>>> vol_right_circ_cone(1, -1)
Traceback (most recent call last):
...
ValueError: vol_right_circ_cone() only accepts non-negative values
"""
if height < 0 or radius < 0:
raise ValueError("vol_right_circ_cone() only accepts non-negative values")
return pi * pow(radius, 2) * height / 3.0
def vol_prism(area_of_base: float, height: float) -> float:
r"""
| Calculate the Volume of a Prism.
| Wikipedia reference: https://en.wikipedia.org/wiki/Prism_(geometry)
:return: :math:`V = B \cdot h`
>>> vol_prism(10, 2)
20.0
>>> vol_prism(11, 1)
11.0
>>> vol_prism(1.6, 1.6)
2.5600000000000005
>>> vol_prism(0, 0)
0.0
>>> vol_prism(-1, 1)
Traceback (most recent call last):
...
ValueError: vol_prism() only accepts non-negative values
>>> vol_prism(1, -1)
Traceback (most recent call last):
...
ValueError: vol_prism() only accepts non-negative values
"""
if height < 0 or area_of_base < 0:
raise ValueError("vol_prism() only accepts non-negative values")
return float(area_of_base * height)
def vol_pyramid(area_of_base: float, height: float) -> float:
r"""
| Calculate the Volume of a Pyramid.
| Wikipedia reference: https://en.wikipedia.org/wiki/Pyramid_(geometry)
:return: :math:`\frac{1}{3} \cdot B \cdot h`
>>> vol_pyramid(10, 3)
10.0
>>> vol_pyramid(1.5, 3)
1.5
>>> vol_pyramid(1.6, 1.6)
0.8533333333333335
>>> vol_pyramid(0, 0)
0.0
>>> vol_pyramid(-1, 1)
Traceback (most recent call last):
...
ValueError: vol_pyramid() only accepts non-negative values
>>> vol_pyramid(1, -1)
Traceback (most recent call last):
...
ValueError: vol_pyramid() only accepts non-negative values
"""
if height < 0 or area_of_base < 0:
raise ValueError("vol_pyramid() only accepts non-negative values")
return area_of_base * height / 3.0
def vol_sphere(radius: float) -> float:
r"""
| Calculate the Volume of a Sphere.
| Wikipedia reference: https://en.wikipedia.org/wiki/Sphere
:return: :math:`\frac{4}{3} \cdot \pi \cdot r^3`
>>> vol_sphere(5)
523.5987755982989
>>> vol_sphere(1)
4.1887902047863905
>>> vol_sphere(1.6)
17.15728467880506
>>> vol_sphere(0)
0.0
>>> vol_sphere(-1)
Traceback (most recent call last):
...
ValueError: vol_sphere() only accepts non-negative values
"""
if radius < 0:
raise ValueError("vol_sphere() only accepts non-negative values")
# Volume is 4/3 * pi * radius cubed
return 4 / 3 * pi * pow(radius, 3)
def vol_hemisphere(radius: float) -> float:
r"""
| Calculate the volume of a hemisphere
| Wikipedia reference: https://en.wikipedia.org/wiki/Hemisphere
| Other references: https://www.cuemath.com/geometry/hemisphere
:return: :math:`\frac{2}{3} \cdot \pi \cdot radius^3`
>>> vol_hemisphere(1)
2.0943951023931953
>>> vol_hemisphere(7)
718.377520120866
>>> vol_hemisphere(1.6)
8.57864233940253
>>> vol_hemisphere(0)
0.0
>>> vol_hemisphere(-1)
Traceback (most recent call last):
...
ValueError: vol_hemisphere() only accepts non-negative values
"""
if radius < 0:
raise ValueError("vol_hemisphere() only accepts non-negative values")
# Volume is radius cubed * pi * 2/3
return pow(radius, 3) * pi * 2 / 3
def vol_circular_cylinder(radius: float, height: float) -> float:
r"""
| Calculate the Volume of a Circular Cylinder.
| Wikipedia reference: https://en.wikipedia.org/wiki/Cylinder
:return: :math:`\pi \cdot radius^2 \cdot height`
>>> vol_circular_cylinder(1, 1)
3.141592653589793
>>> vol_circular_cylinder(4, 3)
150.79644737231007
>>> vol_circular_cylinder(1.6, 1.6)
12.867963509103795
>>> vol_circular_cylinder(0, 0)
0.0
>>> vol_circular_cylinder(-1, 1)
Traceback (most recent call last):
...
ValueError: vol_circular_cylinder() only accepts non-negative values
>>> vol_circular_cylinder(1, -1)
Traceback (most recent call last):
...
ValueError: vol_circular_cylinder() only accepts non-negative values
"""
if height < 0 or radius < 0:
raise ValueError("vol_circular_cylinder() only accepts non-negative values")
# Volume is radius squared * height * pi
return pow(radius, 2) * height * pi
def vol_hollow_circular_cylinder(
inner_radius: float, outer_radius: float, height: float
) -> float:
"""
Calculate the Volume of a Hollow Circular Cylinder.
>>> vol_hollow_circular_cylinder(1, 2, 3)
28.274333882308138
>>> vol_hollow_circular_cylinder(1.6, 2.6, 3.6)
47.50088092227767
>>> vol_hollow_circular_cylinder(-1, 2, 3)
Traceback (most recent call last):
...
ValueError: vol_hollow_circular_cylinder() only accepts non-negative values
>>> vol_hollow_circular_cylinder(1, -2, 3)
Traceback (most recent call last):
...
ValueError: vol_hollow_circular_cylinder() only accepts non-negative values
>>> vol_hollow_circular_cylinder(1, 2, -3)
Traceback (most recent call last):
...
ValueError: vol_hollow_circular_cylinder() only accepts non-negative values
>>> vol_hollow_circular_cylinder(2, 1, 3)
Traceback (most recent call last):
...
ValueError: outer_radius must be greater than inner_radius
>>> vol_hollow_circular_cylinder(0, 0, 0)
Traceback (most recent call last):
...
ValueError: outer_radius must be greater than inner_radius
"""
# Volume - (outer_radius squared - inner_radius squared) * pi * height
if inner_radius < 0 or outer_radius < 0 or height < 0:
raise ValueError(
"vol_hollow_circular_cylinder() only accepts non-negative values"
)
if outer_radius <= inner_radius:
raise ValueError("outer_radius must be greater than inner_radius")
return pi * (pow(outer_radius, 2) - pow(inner_radius, 2)) * height
def vol_conical_frustum(height: float, radius_1: float, radius_2: float) -> float:
"""
| Calculate the Volume of a Conical Frustum.
| Wikipedia reference: https://en.wikipedia.org/wiki/Frustum
>>> vol_conical_frustum(45, 7, 28)
48490.482608158454
>>> vol_conical_frustum(1, 1, 2)
7.330382858376184
>>> vol_conical_frustum(1.6, 2.6, 3.6)
48.7240076620753
>>> vol_conical_frustum(0, 0, 0)
0.0
>>> vol_conical_frustum(-2, 2, 1)
Traceback (most recent call last):
...
ValueError: vol_conical_frustum() only accepts non-negative values
>>> vol_conical_frustum(2, -2, 1)
Traceback (most recent call last):
...
ValueError: vol_conical_frustum() only accepts non-negative values
>>> vol_conical_frustum(2, 2, -1)
Traceback (most recent call last):
...
ValueError: vol_conical_frustum() only accepts non-negative values
"""
# Volume is 1/3 * pi * height *
# (radius_1 squared + radius_2 squared + radius_1 * radius_2)
if radius_1 < 0 or radius_2 < 0 or height < 0:
raise ValueError("vol_conical_frustum() only accepts non-negative values")
return (
1
/ 3
* pi
* height
* (pow(radius_1, 2) + pow(radius_2, 2) + radius_1 * radius_2)
)
def vol_torus(torus_radius: float, tube_radius: float) -> float:
r"""
| Calculate the Volume of a Torus.
| Wikipedia reference: https://en.wikipedia.org/wiki/Torus
:return: :math:`2 \pi^2 \cdot torus\_radius \cdot tube\_radius^2`
>>> vol_torus(1, 1)
19.739208802178716
>>> vol_torus(4, 3)
710.6115168784338
>>> vol_torus(3, 4)
947.4820225045784
>>> vol_torus(1.6, 1.6)
80.85179925372404
>>> vol_torus(0, 0)
0.0
>>> vol_torus(-1, 1)
Traceback (most recent call last):
...
ValueError: vol_torus() only accepts non-negative values
>>> vol_torus(1, -1)
Traceback (most recent call last):
...
ValueError: vol_torus() only accepts non-negative values
"""
if torus_radius < 0 or tube_radius < 0:
raise ValueError("vol_torus() only accepts non-negative values")
return 2 * pow(pi, 2) * torus_radius * pow(tube_radius, 2)
def vol_icosahedron(tri_side: float) -> float:
"""
| Calculate the Volume of an Icosahedron.
| Wikipedia reference: https://en.wikipedia.org/wiki/Regular_icosahedron
>>> from math import isclose
>>> isclose(vol_icosahedron(2.5), 34.088984228514256)
True
>>> isclose(vol_icosahedron(10), 2181.694990624912374)
True
>>> isclose(vol_icosahedron(5), 272.711873828114047)
True
>>> isclose(vol_icosahedron(3.49), 92.740688412033628)
True
>>> vol_icosahedron(0)
0.0
>>> vol_icosahedron(-1)
Traceback (most recent call last):
...
ValueError: vol_icosahedron() only accepts non-negative values
>>> vol_icosahedron(-0.2)
Traceback (most recent call last):
...
ValueError: vol_icosahedron() only accepts non-negative values
"""
if tri_side < 0:
raise ValueError("vol_icosahedron() only accepts non-negative values")
return tri_side**3 * (3 + 5**0.5) * 5 / 12
def main():
"""Print the Results of Various Volume Calculations."""
print("Volumes:")
print(f"Cube: {vol_cube(2) = }") # = 8
print(f"Cuboid: {vol_cuboid(2, 2, 2) = }") # = 8
print(f"Cone: {vol_cone(2, 2) = }") # ~= 1.33
print(f"Right Circular Cone: {vol_right_circ_cone(2, 2) = }") # ~= 8.38
print(f"Prism: {vol_prism(2, 2) = }") # = 4
print(f"Pyramid: {vol_pyramid(2, 2) = }") # ~= 1.33
print(f"Sphere: {vol_sphere(2) = }") # ~= 33.5
print(f"Hemisphere: {vol_hemisphere(2) = }") # ~= 16.75
print(f"Circular Cylinder: {vol_circular_cylinder(2, 2) = }") # ~= 25.1
print(f"Torus: {vol_torus(2, 2) = }") # ~= 157.9
print(f"Conical Frustum: {vol_conical_frustum(2, 2, 4) = }") # ~= 58.6
print(f"Spherical cap: {vol_spherical_cap(1, 2) = }") # ~= 5.24
print(f"Spheres intersection: {vol_spheres_intersect(2, 2, 1) = }") # ~= 21.21
print(f"Spheres union: {vol_spheres_union(2, 2, 1) = }") # ~= 45.81
print(
f"Hollow Circular Cylinder: {vol_hollow_circular_cylinder(1, 2, 3) = }"
) # ~= 28.3
print(f"Icosahedron: {vol_icosahedron(2.5) = }") # ~=34.09
if __name__ == "__main__":
main()
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

Python 算法集
暂无标签
MIT
使用 MIT 开源许可协议
取消

发行版

暂无发行版

开源评估指数源自 OSS-Compass 评估体系,评估体系围绕以下三个维度对项目展开评估:

1. 开源生态

  • 生产力:来评估开源项目输出软件制品和开源价值的能力。
  • 创新力:用于评估开源软件及其生态系统的多样化程度。
  • 稳健性:用于评估开源项目面对多变的发展环境,抵御内外干扰并自我恢复的能力。

2. 协作、人、软件

  • 协作:代表了开源开发行为中协作的程度和深度。
  • 人:观察开源项目核心人员在开源项目中的影响力,并通过第三方视角考察用户和开发者对开源项目的评价。
  • 软件:从开源项目对外输出的制品评估其价值最终落脚点。也是开源评估最"古老"的主流方向之一"开源软件" 的具体表现。

3. 评估模型

    基于"开源生态"与"协作、人、软件"的维度,找到与该目标直接或间接相关的可量化指标,对开源项目健康与生态进行量化评估,最终形成开源评估指数。

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/TheAlgorithms/Python.git
git@gitee.com:TheAlgorithms/Python.git
TheAlgorithms
Python
Python
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /