print ("Functions Menu")
Menu = ["asin","acos","atan","sinh","cosh","tanh"]
Option = ['d','e','f','g','h','i']
for r in range(0,len(Menu)):
print(Option[r],". ",Menu[r])
Flag=1
fun = ' '
while(Flag):
if(fun=='d' or fun=='e' or fun=='f' or fun=='g' or fun=='h' or fun=='i'):
Flag=0
else:
fun = input("Choose the function (d/e/f/g/h/i): ")
a = float(input("Enter the value :"))
dict4 = {'d':math.asin(a), 'e':math.acos(a), 'f':math.atan(a), 'g':math.sinh(a), 'h':math.cosh(a),'i':math.tanh(a)}
print ("The result is : " + Menu[ord(fun)-ord('d')]+"("+str(a)+") = "+str(dict4.get(fun)))
Question:
1. In this program, you are going to create a with getter and setter.
import math
print("Functions Menu")
Menu = ["asin", "acos", "atan", "sinh", "cosh", "tanh"]
Option = ['d', 'e', 'f', 'g', 'h', 'i']
for r in range(0, len(Menu)):
print(Option[r], ". ", Menu[r])
Flag = 1
fun = ' '
while(Flag):
if(fun == 'd' or fun == 'e' or fun == 'f' or fun == 'g' or fun == 'h' or fun == 'i'):
Flag = 0
else:
fun = input("Choose the function (d/e/f/g/h/i): ")
a = float(input("Enter the value :"))
dict4 = {'d': math.asin(a), 'e': math.acos(a), 'f': math.atan(
a), 'g': math.sinh(a), 'h': math.cosh(a), 'i': math.tanh(a)}
print("The result is : " + Menu[ord(fun)-ord('d')
]+"("+str(a)+") = "+str(dict4.get(fun)))
Comments
Leave a comment