module #15
module
#15
Replies: 4 comments
-
计算圆面积import math
def circle_area(radius):
return math.pi * radius ** 2
print(circle_area(5)) |
Beta Was this translation helpful? Give feedback.
0 replies
-
将角度转换为弧度import math
print(math.radians(180)) |
Beta Was this translation helpful? Give feedback.
0 replies
-
最大公约数和最小公倍数import math
a, b = 48, 18
gcd = math.gcd(a, b) # 最大公约数
lcm = abs(a * b) // gcd # 最小公倍数
print(gcd, lcm) |
Beta Was this translation helpful? Give feedback.
0 replies
-
求解二元二次方程组我们可以使用 sympy 库来求解方程组。比如求解系列方程组: from sympy import symbols, Eq, solve
# 定义变量
x, y = symbols('x y')
# 输入系数
a, b, c, d, e, f = 1, 1, 1, 1, 1, 1 # 示例系数
g, h, i, j, k, l = 1, 1, 1, 1, 1, 1 # 示例系数
# 定义方程
equation1 = Eq(a * x**2 + b * y**2 + c * x * y + d * x + e * y + f, 0)
equation2 = Eq(g * x**2 + h * y**2 + i * x * y + j * x + k * y + l, 0)
# 求解方程组
solutions = solve((equation1, equation2), (x, y))
# 输出结果
print(f"解为: {solutions}") |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
module
在 Python 中,模块是一种组织和重用代码的方式。一个模块基本上就是一个包含 Python 代码的 .py 文件。这些文件可以包含可执行的代码、函数、类或变量。模块不仅仅是提供代码重用的方式,它们还可以帮助我们更好地组织和管理复杂的代码。
https://py.qizhen.xyz/module
Beta Was this translation helpful? Give feedback.
All reactions