# Simple Calculator Program in Python

Write a python program to create a menu-driven calculator that performs the basic arithmetic operations (+, -, *, /, and %).

Input

The input will be a single line containing two integers and operator (+, -, *, /, and %) similar to 3 5.

Output

If the given operator is “+”, print the sum of two numbers.
If the given operator is “-“, print the result of the subtraction of the two numbers.
If the given operator is “*”, print the multiplication of the two numbers.
If the given operator is “/”, print the result of the division of the two numbers.
If the given operator is “%”, print the result of the modulus operation of the two numbers.

Explanation

For example, if the given operator is “+” and the two numbers are 3 and 5. As it is an addition operator, your code should print the sum of the given two numbers (3 + 5), which is 8.

Similarly, if the given operator is “* and the two numbers are 2 and 5. As it is a multiplication operator, your code should print the result of the multiplication of the given two numbers (2 * 5), which is 10.

Similarly, if the given operator is “-” and the two numbers are 10 and 9. As it is a subtraction operator, your code should print the result of the subtraction of the given two numbers (10 – 9), which is 1.

Sample Input 1
3 + 5

Sample Output 1
8

Code:

``````string=input().split()
a=string[0]
b=string[2]
a=int(a)
b=int(b)

if string[1]=="+":
d=a+b
print(d)
elif string[1]=="-":
d=a-b
print(d)
elif string[1]=="*":
d=a*b
print(d)
elif string[1]=="/":
d=a/b
print(d)
elif string[1]=="%":
d=a%b
print(d)``````

Input
10 * 10

Output
100

## Python Program to Convert Integer into a Single Numeral

Single Digit Number Ram is given a positive integer N .He wishes to convert this integer into a single numeral. He does so by repeatedly adding the…

## Python Program to Print Armstrong numbers between two intervals￼

Write a program to print all the Armstrong numbers in the given range A to B (including A and B). An N – digit number is an…

## Python Program to Check if Given Input is a Letter, Digit or Special Character￼

Letter, Digit or Special Character You are given a character as input. Check if the given input is a Lowercase Letter or Uppercase Letter or Digit or…

## Interleave Strings | Python Program to merge two strings by adding characters in alternating order

Interleave Strings Given two strings, write a program to merge the given two strings by adding characters in alternating order, starting with the first string. If a…

## Python Program to Check if given colors are present in the color palate

Shekhar is an artist. He likes to draw and paint. He is now drawing a portrait of a city road which is in the black color and…

## Python Program to Check the eligibility criteria for donor

Python Comparison Operators An XYZ hospital has organised a blood donation camp. The eligibility criteria for donor was as follows  1) Age>=18  2) Weight >=50 kg  3)…