Discuss / Python / 交作业,想问下程序中的退出怎么做,比如exit这样

交作业,想问下程序中的退出怎么做,比如exit这样

Topic source

落落96897

#1 Created at ... [Delete] [Delete and Lock User]
# -*- coding: utf-8 -*-import mathdef quadratic(a, b, c):    x1=0    x2=0    if not isinstance(a,(int,float)) or not isinstance(a,(int,float)) or not isinstance(a,(int,float)):        raise TypeError('bad operand type')    if a == 0:        print('分母a不能为0!')    elif ((b*b-4*a*c)<0):        print('负数无法开平方!')    else:        x1=(-b+math.sqrt(b*b-4*a*c))/2*a        x2=(-b-math.sqrt(b*b-4*a*c))/2*a        return x1,x2d =  quadratic('0',3,1)if d==None:    print('此方程误解!')else:    print(d)

  • 1

Reply