Answer to Question #165543 in Python for B Mani teja

Question #165543

Write a program to create a menu-driven calculator that performs 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.

Similarly, if the given operator is "%" and the two numbers are 20 and 10.

As it is a Modulus operator, your code should print the result of the remainder of the given two numbers (20 % 10), which is 0.



1
Expert's answer
2021-02-21T19:49:37-0500
num1 = int(input("Enter a Number: "))
num2 = int(input("Enter another Number: "))
operator = str(input("Enter the Operation you want: "))

if operator == "+":
    print("Result is:" , (num1 + num2))

elif operator == "-":
    print("Result is:" , (num1 - num2))

elif operator == "*":
    print("Result is:" , (num1 * num2))

elif operator == "/":
    print("Result is:" , (num1 / num2))

elif operator == "%":
    print("Result is:" , (num1 % num2))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Assignment Expert
20.05.21, 14:37

Dear chandra the code works well

chandra
20.05.21, 13:55

for this code line 1 showing error

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS