PyScripter3.6配置pandas numpy和matplotlib
20200713104445.jpg
解一元二次方程:
#-------------------------------------------------------------------------------
# Name: 解一元二次方程
# Purpose: 解一元二次方程
#-------------------------------------------------------------------------------
import math as m
def main():
a = int(input("a="))
b = int(input("b="))
c = int(input("c="))
deta = int(b * b - 4 * a * c);
if(deta >= 0):
x1 = (-b + m.sqrt(deta))/(2 * a)
x2 = (-b - m.sqrt(deta))/(2 * a)
else:
x1 = x2 = "no key"
print("x1=", x1)
print("x2=", x2)
if __name__ == '__main__':
main()
输出:
a=10
b=52
c=65
x1= -2.0900980486407215
x2= -3.1099019513592787
>>>
网友评论