- 博客(2)
- 收藏
- 关注
原创 (Python)求x与y最大公约数,assert语句约束x,y均大于1
while True: try: x = int(input("input x:")) y = int(input("input y:")) assert x > 1 and y > 1,'x and y > 1' a = x b = y if a < b: a,b = b,a print(a,b) while b!.
2022-03-22 20:44:59 943
原创 Python 解一元二次方程ax^2+bx+c=0
from math import *a = float(input("a:"))b = float(input("b:"))c = float(input("c:")) if a == 0: print("x=",-c/b)else: beta = b**2-4*a*c #b**2是b的平方 if beta > 0: x1 = (-b + sqrt(beta))/(2*a) #记得大括号 x2 = (-b - sqrt(be.
2022-03-03 21:13:21 14929
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人