题解 | #简单计算器#
简单计算器
https://www.nowcoder.com/practice/b8f770674ba7468bb0a0efcc2aa3a239
n=input() if "+"in n: a=float(n.split("+")[0]) b=float(n.split("+")[1]) print(f"{a:.4f}+{b:.4f}={a+b:.4f}") elif "-"in n: a=float(n.split("-")[0]) b=float(n.split("-")[1]) print(f"{a:.4f}-{b:.4f}={a-b:.4f}") elif "*"in n: a=float(n.split("*")[0]) b=float(n.split("*")[1]) print(f"{a:.4f}*{b:.4f}={a*b:.4f}") elif "/" in n: a=float(n.split("/")[0]) b=float(n.split("/")[1]) if b==0.0: print("Wrong!Division by zero!") else: print(f"{a:.4f}/{b:.4f}={a/b:.4f}") else: print("Invalid operation!")