有疑问。。。
Topic source写错了,忘记优先级了。。。
#!/usr/bin/env python
# encoding: utf-8
import math
def quadratic(a,b,c):
''' Solving a quadratic equation,
giving the values of a, b, c
(a, b, c the need for integral or floating-point type),
and then calculate the equation of a*x*x + b*x + c = 0.
'''
TestEquation = b**2 - 4*a*c
for TestNumber in (a, b, c):
if not isinstance(TestNumber, (int, float)):
raise TypeError('bad operand type')
if a == 0:
print("Value a cannot be '0'!")
elif TestEquation >= 0:
print("Solving the equation")
values1 =(math.sqrt(TestEquation) + b) / (2*a)
values2 =(math.sqrt(TestEquation) - b) / (2*a)
print("The equation values1 is: %s, values2 is: %s" % (values1,values2))
else:
print("No solution equation")
try:
a, b, c = map(float, input("Enter a, b, c:").split(',')[:3])
print(a,b,c)
except ValueError:
print("Wrrong Values")
quadratic(a,b,c)
- 1
HOMO-SUM
本来输入想用下面这种方法:
但是不知道怎么和:
结合。。。。