一道Python的编程题(要求如图),帮忙写一下代码,谢谢
if __name__ == "__main__":
m = float(input("请输入铁丝的长度:"))
n = float(input("请输入面积:"))
#高为h,宽为w=m/2-h
#n=h×(m/2-h)
#-h^2+(m/2)*h-n=0
#判断是否有解
if m*m/4.0-4*n < 0:
print("此问题无解!")
elif m*m/4.0-4*n == 0:
print("此问题一个解:")
h = (-m/2+(m*m/4.0-4*n)**0.5)/-2.0
w = m/2 - h
print("h=%f w=%f" % (h,w))
else:
print("此问题两个解:")
h = (-m/2+(m*m/4.0-4*n)**0.5)/-2.0
w = m/2 - h
print("h=%f w=%f" % (h,w))
h = (-m/2-(m*m/4.0-4*n)**0.5)/-2.0
w = m/2 - h
print("h=%f w=%f" % (h,w))
print()
代码及运行结果如图所示,望采纳!