Advertisement
simeonshopov

Calculations

Dec 10th, 2019
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. operator = input()
  2. first_num =  int(input())
  3. second_num = int(input())
  4.  
  5.  
  6. def solve(a, b, op):
  7.     if op == 'subtract':
  8.         result = a - b
  9.     elif op == 'add':
  10.         result = a + b
  11.     elif op == 'divide':
  12.         result = a / b
  13.     elif op == 'multiply':
  14.         result = a * b
  15.     return round(result)
  16.  
  17.  
  18. print(solve(first_num, second_num, operator))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement