# write a micrpythn program to make a clculator
import math
def calculator():
while True:
print("\nSimple Calculator")
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
print("5. Square")
print("6. Square Root")
print("7. Logarithm")
print("8. Sine")
print("9. Cosine")
print("10. Tangent")
print("11. Exit")
choice = int(input("Enter choice (1/2/3/4/5/6/7/8/9/10/11): "))
if choice not in range(1, 12):
print("Invalid choice. Please enter a number between 1 and 11.")
continue
if choice == 11:
break
num1 = float(input("Enter first number: "))
if choice == 5:
print("Square of", num1, "=", math.pow(num1, 2))
elif choice == 6:
print("Square root of", num1, "=", math.sqrt(num1))
elif choice == 7:
base = float(input("Enter base (default is e): "))
print("Logarithm of", num1, "to the base", base, "=", math.log(num1, base))
elif choice in [8, 9, 10]:
angle = float(input("Enter angle in degrees: "))
print(["sin", "cos", "tan"][choice-8], "of", angle, "=", math.sin(math.radians(angle))) if choice == 8 else print(["sin", "cos", "tan"][choice-8], "of", angle, "=", math.cos(math.radians(angle))) if choice == 9 else print(["sin", "cos", "tan"][choice-8], "of", angle, "=", math.tan(math.radians(angle)))
else:
num2 = float(input("Enter second number: "))
print(num1, "+", num2, "=", num1 + num2)
if choice == 1 else print(num1, "-", num2, "=", num1 - num2) if choice == 2 else print(num1, "*", num2, "=", num1 * num2) if choice == 3 else print(num1, "/", num2, "=", num1 / num2) if choice == 4 and num2 != 0 else print("Error! Division by zero is not allowed.")
calculator()