Simple Calculator :- Write a program to create a menu driven calculator that performs basic arithmetic operations (,l, and %).

PHOTO EMBED

Fri Nov 04 2022 18:56:39 GMT+0000 (Coordinated Universal Time)

Saved by @codewithakash

char = input()
a = int(input())
b = int(input())

add = "+"
sub = "-"
mul = "*"
div = "/"
mod = "%"

if add == char:
    add = a + b
    print(add)
elif sub == char:
    sub = a - b
    print(sub)
elif mul == char:
    mul = a * b
    print(mul)
elif div == char:
    div = a / b
    print(div)
elif mod == char:
    mod = a % b
    print(mod)
content_copyCOPY

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.

https://learning.ccbp.in/crash-course/coding/efd285cb-2566-4aea-b406-de162be87464