Answer to Question #267155 in Python for Matteo Villamor

Question #267155

#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()


Question:

1. In this program, you are going to create a with getter and setter.


1
Expert's answer
2021-11-18T23:54:21-0500
#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()
#Creating a class for calculating getter and setter 
class GetterSetter:
	def __init__(self, age = 0):
		self._age = age
	
	# getter method
	def get_age(self):
		return self._age
	
	# setter method
	def set_age(self, x):
		self._age = x


raj = GetterSetter()


#you can add age using setter
raj.set_age(21)


# this is retrieving age using getter
print(raj.get_age())


print(raj._age)

#The iterations had many mistakes in given code and I fixed it 

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