if op==1 or op==2 or op==3 or op==4 or op==5 or op==6 :
a = int(input("Enter first number"))
b = int(input("Enter second number"))
dict1 = {1:a+b, 2:a-b, 3:a*b, 4:a/b, 5:a%b, 6:a**b}
print ("The result is : " + str(dict1.get(op)))
elif op==7 or op==8 or op==9 or op==10 or op==11 or op==12 :
a = float(input("Enter the number"))
dict2 = {7:math.fabs(a), 8:math.factorial(a), 9:math.log(a), 10:math.ceil(a), 11:math.floor(a), 12:math.sqrt(a)}
print ("The result is : " + str(dict2.get(op)))
elif op==13 :
print ("Functions Menu")
print ("a. sin")
print ("b. cos")
print ("c. tan")
fun = input("Choose the function :")
a = float(input("Enter the angle in radians :"))
dict3 = {'a':math.sin(a), 'b':math.cos(a), 'c':math.tan(a)}
print ("The result is : " + str(dict3.get(fun)))
Question:
1. In this program, you will create a class and OOP.
import math
op = int(input("Option (1 ... 13): "))
if op == 1 or op == 2 or op == 3 or op == 4 or op == 5 or op == 6:
a = int(input("Enter first number"))
b = int(input("Enter second number"))
dict1 = {1: a+b, 2: a-b, 3: a*b, 4: a/b, 5: a % b, 6: a**b}
print("The result is : " + str(dict1.get(op)))
elif op == 7 or op == 8 or op == 9 or op == 10 or op == 11 or op == 12:
a = float(input("Enter the number"))
dict2 = {7: math.fabs(a), 8: math.factorial(a), 9: math.log(
a), 10: math.ceil(a), 11: math.floor(a), 12: math.sqrt(a)}
print("The result is : " + str(dict2.get(op)))
elif op == 13:
print("Functions Menu")
print("a. sin")
print("b. cos")
print("c. tan")
fun = input("Choose the function :")
a = float(input("Enter the angle in radians :"))
dict3 = {'a': math.sin(a), 'b': math.cos(a), 'c': math.tan(a)}
print("The result is : " + str(dict3.get(fun)))
Comments
Leave a comment