按照题目给的代码,确实是输出5.0。输出改成“print("%.2f" % b)"或"print(format(b, '.2f'))"都可以。
print("%.2f" % b) print(format(b, '.2f'))