问题:python 在同一行依次输入三个值a,b,c,用空格分开,输出 b*b-4*a*c的值
满意答案:
#拒绝回答一系列代码细节,自行百度学习对应函数
import re
import math
print("Input four numbers seperated by scape, enter `#` for ending input")
myinputs = []
t = input("four numbers:")
while t != "#":
tmp = re.split("\s+",t)
tmp = tuple([float(i) for i in tmp])
if len(tmp) != 4:
print("Wrong input! input another one")
else:
print("Other pair of points or `#` for ending?")
myinputs.append(tmp)
t = input("four numbers:")
print("Input pairs of points:")
for i in myinputs:
print(i)
print("The distances:")
for i in myinputs:
d = math.sqrt((i[0]-i[2])**2 + (i[1]-i[3])**2)
print("%.2f" % d)
'''
例子如下
Input four numbers seperated by scape, enter `#` for ending input
four numbers:1 1 2 2
Other pair of points or `#` for ending?
four numbers:2 3 4 5
Other pair of points or `#` for ending?
four numbers:#
Input pairs of points:
(1.0, 1.0, 2.0, 2.0)
(2.0, 3.0, 4.0, 5.0)
The distances:
1.41
2.83
'''
其他回答:
这种函数很简单的吧其他回答:
a=input('请输入')
b=input('请输入')
c=input('请输入')
print(b*b-4*a*c)