Answer to Question #267153 in Python for Matteo Villamor

Question #267153

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.

1
Expert's answer
2021-11-18T06:46:48-0500
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)))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS