python解决ax^2+bx+c=0
使用IDE为PyCharm
首先是添加numpy包操作如下
第一步 File ->settings说明
numpy的sqrt可以对正负数进行开方 ,可以处理ax^2+bx+c=0的所有情况,即sqrt 对实数、复数统一处理
实现代码如下from numpy.lib.scimath import sqrt a = int(input()) b = int(input()) c = int(input()) if a == 0: if b == 0 and c ==0: print("There are infinitely many solutions!") else: if b==0: print ("There is no solution") else: print("There is a unique solution x=%g" %(-1*c/b)) else: disc = b*b -4*a*c if disc > 0: x1 = (-b + sqrt(disc)) / 2 / a x2 = (-b - sqrt(disc)) / 2 / a if disc > 0: print("There are two distinct real roots x1=%g and x2=%g" % (x1, x2)) else: print("There are two conjugate roots x1=%g and x2=%g" % (x1, x2)) else: if disc == 0: print("There are two equal real roots x1=x2=%g" % (-1 * b / 2 / a)) else: x1 = (-b + sqrt(disc)) / 2 / a x2 = (-b - sqrt(disc)) / 2 / a print("There are two conjugate roots x1=%s and x2=%s" % (x1, x2))
123456789101112131415161718192021222324252627282930相关知识
使用 OpenCV 和 FER 在 Python 中进行实时情绪识别
php表达式ax 2 bx c=0,python求解ax² + bx + c = 0
python打印一定范围内的素数
宁波AX宠物医院发展战略研究
python运行run在哪
Python学习手册
设含有 m个方程的n元非齐次线性方程组为Ax=b且R(A)=r, 则( )
python 练习题
Python笔试题
python学习总结day2
网址: python解决ax^2+bx+c=0 https://www.mcbbbk.com/newsview348389.html
上一篇: 《宠物的秘密生活》电视剧全集在线 |
下一篇: 宠物记录1 |
推荐分享

- 1我的狗老公李淑敏33——如何 5096
- 2南京宠物粮食薄荷饼宠物食品包 4363
- 3家养水獭多少钱一只正常 3825
- 4豆柴犬为什么不建议养?可爱的 3668
- 5自制狗狗辅食:棉花面纱犬的美 3615
- 6狗交配为什么会锁住?从狗狗生 3601
- 7广州哪里卖宠物猫狗的选择性多 3535
- 8湖南隆飞尔动物药业有限公司宠 3477
- 9黄金蟒的价格 3396
- 10益和 MATCHWELL 狗 3352