输入二次函数系数求平方根

使用spyder环境进行编辑(因为方便一点),用python语言,(菜鸟一个,大神轻喷,希望所有程序猿头发越来越茂密)   代码如下:

from math import sqrt
a = float(input('a='))
b = float(input('b='))
c = float(input('c='))
delta =b**2-4*a*c
if delta>=0:
    x1=(-b+sqrt(delta))/(2*a)
    x2=(-b-sqrt(delta))/(2*a)
    print('此方程为{}x^2+{}x+{}'.format(a,b,c))
else:
    print('此方程无平方根')

效果图:

猜你喜欢

转载自blog.csdn.net/weixin_62499894/article/details/121411087
今日推荐