python tip

Smart Calculator

This amazing tip and trick will help you to make a calculator without using the If-Else condition. I had used the built-in operator module and dictionary method.

# Smart Calculator without if elseimport operatoractions = {    "+" : operator.add,    "-" : operator.sub,    "*" : operator.mul,    "/" : operator.truediv}print(actions["+"](12, 45)) # 57print(actions["-"](12, 45)) # -33