Two Integers Plus or Minus

The program must accept two integers A,B separated by a string S (whose value is plus or minus). Based on the string value S, the program must print the sum or difference between the integers.

Input Format:
The first line contains A,S and B separated by a space.

Output Format:
The first line contains the integer value.

Example Input/Output 1:
Input:
3 plus 12

Output:
15

Example Input/Output 2:
Input:
100 minus 25

Output:
75

a,s,b=map(str,input().split())
a,b=int(a),int(b)
if s=='PLUS' or s=='plus' or s=='Plus':
    print(a+b)
else:
    print(a-b)
Previous Article

Sorted or Not

Next Article

Merge Sorted Descending

Write a Comment

Leave a Comment

Your email address will not be published. Required fields are marked *