Answer to Question #265537 in Python for Matteo Villamor

Question #265537


elif op==16 :


print ("Functions Menu")


print ("j. asinh")


print ("k. acosh")


print ("l. atanh")


fun = raw_input("Choose the function :")


a = float(input("Enter the value :"))


dict6 = {'j':math.asinh(a), 'k':math.acosh(a), 'l':math.atanh(a)}


print ("The result is : " + str(dict6.get(fun)) )



else :


print ("Wrong Choice")




Question:


1. In this program, you will create a class and OOP.

1
Expert's answer
2021-11-15T00:30:59-0500


SOLUTION TO THE ABOVE QUESTION


SOLUTION CODE


#Let us import the math library
import cmath
#Create a class and call it calculator
class Calculator:
    #define a method a call it trigonometry
    def trigonometry(self):
        print("Functions Menu")

        print("j. asinh")

        print("k. acosh")

        print("l. atanh")

        fun = input("Choose the function :")

        if (fun == 'l' or fun == 'k' or fun == 'j'):

            a = float(input("Enter the value :"))

            dict6 = {'j': cmath.asinh(a), 'k': cmath.acosh(a), 'l': cmath.atanh(a)}

            print("The result is : " + str(dict6.get(fun)))

        else:
            print("Wrong Choice")



# create a new object of Calculator class
my_calc = Calculator()

# Calling object's trigonometry() method
my_calc.trigonometry()


SAMPLE PROGRAM OUTPUT






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