0% found this document useful (0 votes)
8 views1 page

Leve 3

Uploaded by

ravipal33759
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Leve 3

Uploaded by

ravipal33759
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

def add(x, y):

return x + y

def subtract(x, y):


return x - y

def multiply(x, y):


return x * y

def divide(x, y):


if y == 0:
return "Error! Division by zero."
return x / y

def power(x, y):


return x ** y

def mod(x, y):


return x % y

def display_menu():
print("\nSelect operation:")
print("1. Add")
print("2. Subtract")
print("3. Multiply")
print("4. Divide")
print("5. Power")
print("6. Modulo")
print("7. Exit")

def main():
while True:
display_menu()

try:
choice = int(input("Enter choice (1/2/3/4/5/6/7): "))

if choice == 7:
print("Exiting the calculator. Goodbye!")
break

if choice in (1, 2, 3, 4, 5, 6):


num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))

if choice == 1:
print(f"{num1} + {num2} = {add(num1, num2)}")
elif choice == 2:

You might also like