Discuss / Python / 有点乱,不过终于不再出错了

有点乱,不过终于不再出错了

Topic source

奮進_V

#1 Created at ... [Delete] [Delete and Lock User]

import math def quadratic(a,b,c): if (b^2-4ac) >= 0 and a != 0: x1 = (math.sqrt(b^2-4ac) - b) / (2a) x2 = (-math.sqrt(b^2-4ac) - b ) / (2a) return x1,x2 def xh(): n = 0 e = [1,2,3] u = ['a','b','c'] while n < 3: e[n] = float(input('请输入%s的值\n'%u[n])) n = n + 1 return quadratic(e[0],e[1],e[2]) def cx(): t = xh() while t == None: print('输入有误,重新输入!\n') t = xh() print(t) while t != None: s = input('还要计算吗?Y/N\n') if s == 'Y' or s == 'y': t = cx() elif s == 'N' or s == 'n': break else: print('输入有误') continue cx()


  • 1

Reply