develop a menu driven python program to design a simple calculator. code example

Example 1: calculator in python

def mutiply (x):
    return 5*x
o = mutiply(10)
print(o)

Example 2: calculator code

x = input("first number")
y = input("second number")
z = input("do you want to multiply, minus, divide or add? (x,-,/,+)")

y = int(y)
x = int(x)

if z == "+":
    print (x + y)

if z == "/":
    print (x / y)

if z == "x":
    print (x * y)

if z == "-":
    print (x - y)

else:
    print("use x,-,/ or + next time!")

Tags: