Queer European MD passionate about IT

interpreter.py 405 B

1234567891011121314151617
  1. def main():
  2. expression = input("Enter an arithmetic expression:\t\t")
  3. x, y, z = expression.split()
  4. result = 0.0
  5. if y == '+':
  6. result = int(x) + int(z)
  7. elif y == '-':
  8. result = int(x) - int(z)
  9. elif y == '*':
  10. result = int(x) * int(z)
  11. elif y == '/':
  12. result = int(x) / int(z)
  13. print(round(float(result), 1))
  14. if __name__ == "__main__":
  15. main()