import math
import statistics
def add(x, y):
return x + y
def sub(x, y):
return x - y
def multi(x, y):
return x * y
def divi(x, y):
if y == 0:
print("y cannot be zero")
return None
else:
return x / y
def modul(x, y):
if y == 0:
print(y, "cannot be zero")
return None
else:
return x % y
def squ(x):
return x ** 2
def even_or_odd(x):
if x % 2 == 0:
print(x, "is even")
else:
print(x, "is odd")
def cube(x):
return x ** 3
def squr_root(x):
return x ** 0.5
def power(x, y):
return math.pow(x, y)
def expo(x):
return math.exp(x)
def abso(x):
return math.fabs(x)
def sin_val(x):
return math.sin(x)
def cos_val(x):
return math.cos(x)
def tan_val(x):
return math.tan(x)
def mean(x):
return statistics.mean(x)
def mod(x):
return statistics.mode(x)
def median(x):
return statistics.median(x)
def log_val(x):
if x <= 0:
print("x should be positive")
return None
else:
return math.log(x)
def q_r(x, y):
return divi(x, y) # using divi function for quotient and remainder
def area_rectangle(x, y):
return x * y
def area_square():
a = int(input("Enter a side length of the square: "))
return a ** 2
def area_circle():
a = int(input("Enter a diameter of the circle: "))
radius = a / 2
return 3.14159 * (radius ** 2)
def area_triangle():
a = int(input("Enter height: "))
b = int(input("Enter base: "))
return (a * b) / 2
# Input list of numbers
L = []
A = int(input("Enter number of elements in the list: "))
for i in range(A):
w = int(input("Enter an element: "))
L.append(w)
# Input x and y values
n = int(input("Enter a value for x: "))
n1 = int(input("Enter a value for y: "))
# Display options
print("1. Addition")
print("2. Subtraction")
print("3. Multiply")
print("4. Division")
print("5. Remainder")
print("6. Square of number")
print("7. Check if number is even or odd")
print("8. Cube of number")
print("9. Square root of number")
print("10. Power of number")
print("11. Exponent of number")
print("12. Absolute value of number")
print("13. Sin value of number")
print("14. Cos value of number")
print("15. Tan value of number")
print("16. Mean of list")
print("17. Median of list")
print("18. Mode of list")
print("19. Log of number")
print("20. Quotient and Remainder")
print("21. Area of rectangle")
print("22. Area of square")
print("23. Area of circle")
print("24. Area of triangle")
print("25. Radian to Degree")
print("26. Degree to Radian")
print("27. Exit")
choice = int(input("Enter your choice: "))
if choice == 1:
print("Sum of", n, "and", n1, "is:", add(n, n1))
elif choice == 2:
print("Difference of", n, "and", n1, "is:", sub(n, n1))
elif choice == 3:
print("Product of", n, "and", n1, "is:", multi(n, n1))
elif choice == 4:
print("Result of division:", divi(n, n1))
elif choice == 5:
print("Remainder of", n, "and", n1, "is:", modul(n, n1))
elif choice == 6:
print("Square of", n, "is:", squ(n))
elif choice == 7:
even_or_odd(n)
elif choice == 8:
print("Cube of", n, "is:", cube(n))
elif choice == 9:
print("Square root of", n, "is:", squr_root(n))
elif choice == 10:
print("Power of", n, "to", n1, "is:", power(n, n1))
elif choice == 11:
print("Exponent of", n, "is:", expo(n))
elif choice == 12:
print("Absolute value of", n, "is:", abso(n))
elif choice == 13:
print("Sin value of", n, "is:", sin_val(n))
elif choice == 14:
print("Cos value of", n, "is:", cos_val(n))
elif choice == 15:
print("Tan value of", n, "is:", tan_val(n))
elif choice == 16:
print("Mean of the list", L, "is:", mean(L))
elif choice == 17:
print("Median of the list", L, "is:", median(L))
elif choice == 18:
print("Mode of the list", L, "is:", mod(L))
elif choice == 19:
print("Log value of", n, "is:", log_val(n))
elif choice == 20:
print("Quotient and Remainder of", n, "and", n1, "are:", q_r(n, n1))
elif choice == 21:
print("Area of rectangle:", area_rectangle(n, n1))
elif choice == 22:
print("Area of square:", area_square())
elif choice == 23:
print("Area of circle:", area_circle())
elif choice == 24:
print("Area of triangle:", area_triangle())
elif choice == 25:
radian = int(input("Enter angle in radian: "))
degree = radian * 180 / 3.14159
print("Angle in degrees:", degree)
elif choice == 26:
degree = int(input("Enter angle in degree: "))
radian = degree * 3.14159 / 180
print("Angle in radians:", radian)
else:
print("Thank you!")