Advertisement
biswasrohit20

pygold

Mar 11th, 2021
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. num1 = float(input("Please enter the first number: "))
  2. checkError = True
  3. while checkError:
  4. operation = int(input("Do you want to: \n 1) Add; 2) Subtract; 3) Multiply; 4) Divide: "))
  5. arr = [1,2,3,4]
  6. if operation in arr:
  7. checkError = False
  8. print("Invalid input!! Please try again")
  9.  
  10. num2 = float(input("Please enter the final number: "))
  11.  
  12. if operation == 1:
  13. result = num1 + num2
  14. elif operation == 2:
  15. result = num1 - num2
  16. elif operation == 3:
  17. result = num1 * num2
  18. elif operation == 4:
  19. result = num1 / num2
  20. print(f'The result is {result}')
  21.  
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement