# Python | Calculator using lambda

``````add = lambda a, b: a + b
subtract = lambda a, b: a - b
multiply = lambda a, b: a * b
divide = lambda a, b: a / b

while True:
print("""\nEnter
2. Subtraction
3. Multiplication
4. Division
5. Exit""")
try:
choice = int(input('\nEnter choice: '))
except:
print('Enter integer values only!')
continue
if 1<=choice<=5:
if choice==5:
print('Exiting...\n')
break
numbers = [int(i) for i in input('Enter numbers: ').split()]
if choice==1:
print('\nResult is: ', add(numbers[0], numbers[1]), '\n')
continue
if choice==2:
print('\nResult is: ', subtract(numbers[0], numbers[1]), '\n')
continue
if choice==3:
print('\nResult is: ', multiply(numbers[0], numbers[1]), '\n')
continue
if choice==4:
print('\nResult is: ', divide(numbers[0], numbers[1]), '\n')
continue
else:
print('Enter choice between 1 and 5')``````

Output:

```PS C:\CopyAssignment.py"

Enter
2. Subtraction
3. Multiplication
4. Division
5. Exit

Enter choice: ds
Enter integer values only!

Enter
2. Subtraction
3. Multiplication
4. Division
5. Exit

Enter choice: 1
Enter numbers: 1 2

Result is:  3

Enter
2. Subtraction
3. Multiplication
4. Division
5. Exit

Enter choice: 4
Enter numbers: 25 4

Result is:  6.25

Enter
2. Subtraction
3. Multiplication
4. Division
5. Exit

Enter choice: 9
Enter choice between 1 and 5

Enter