This action will force synchronization from 编程语言算法集/Python, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
from __future__ import annotationsdef check_polygon(nums: list[float]) -> bool:"""Takes list of possible side lengths and determines whether atwo-dimensional polygon with such side lengths can exist.Returns a boolean value for the < comparisonof the largest side length with sum of the rest.Wiki: https://en.wikipedia.org/wiki/Triangle_inequality>>> check_polygon([6, 10, 5])True>>> check_polygon([3, 7, 13, 2])False>>> check_polygon([1, 4.3, 5.2, 12.2])False>>> nums = [3, 7, 13, 2]>>> _ = check_polygon(nums) # Run function, do not show answer in output>>> nums # Check numbers are not reordered[3, 7, 13, 2]>>> check_polygon([])Traceback (most recent call last):...ValueError: Monogons and Digons are not polygons in the Euclidean space>>> check_polygon([-2, 5, 6])Traceback (most recent call last):...ValueError: All values must be greater than 0"""if len(nums) < 2:raise ValueError("Monogons and Digons are not polygons in the Euclidean space")if any(i <= 0 for i in nums):raise ValueError("All values must be greater than 0")copy_nums = nums.copy()copy_nums.sort()return copy_nums[-1] < sum(copy_nums[:-1])if __name__ == "__main__":import doctestdoctest.testmod()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。