fork download
  1. def add(x, y):
  2. return x + y
  3.  
  4. def subtract(x, y):
  5. return x - y
  6.  
  7. def multiply(x, y):
  8. return x * y
  9.  
  10. def divide(x, y):
  11. if y == 0:
  12. return "Error: Division by zero is not allowed"
  13. else:
  14. return x / y
  15.  
  16. print("Simple Calculator")
  17. print("1. Addition")
  18. print("2. Subtraction")
  19. print("3. Multiplication")
  20. print("4. Division")
  21.  
  22. choice = input("Enter your choice (1-4): ")
  23.  
  24. if choice in ['1', '2', '3', '4']:
  25. num1 = float(input("Enter first number: "))
  26. num2
Success #stdin #stdout 0.09s 14188KB
stdin
Calculater
stdout
Simple Calculator
1. Addition
2. Subtraction
3. Multiplication
4. Division
Enter your choice (1-4):