logo

Crowdly

Browser

Add to Chrome

Hyperbolic Write a module  hyperbolic.py  consisting of methods that implement...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Hyperbolic

Write a module hyperbolic.py consisting of methods that implement the hyperbolic functions based on the definitions and . First write the methods for sinh and cosh. By making use of these two implementations, write functions that implement the function , , , and , defined in a manner analogous to standard trigonometric functions. Test your implementations by adding a main method that accepts one command-line parameter x and prints the results of each method. The output should look as follows: / Skryf 'n module hyperbolic.py wat bestaan uit metodes wat die hiperboliese funksies implementeer gebaseer op die definisies en . Skryf eers die metodes vir sinh en cosh neer. Deur gebruik te maak van hierdie twee metodes, skryf statiese metodes wat die funksie , , , en implementeer, gedefinieer op 'n wyse analoog aan standaard trigonometriese funksies. Toets jou implementerings deur 'n main metode by te voeg wat een opdragreëlparameter x aanvaar en die resultate van elke metode druk. 'n Korrekte implementering sal die volgende resultate lewer:

$ python hyperbolic.py 0.2

sinh(0.200000) = 0.201336

cosh(0.200000) = 1.020067

tanh(0.200000) = 0.197375

coth(0.200000) = 5.066490

sech(0.200000) = 0.980328

csch(0.200000) = 4.966822

Now write client program hyper_client.py (it's file should be in the same directory as the hyperbolic module) that takes two commen-line parameters func_type and value and prints out the computed hyperbolic value of value based on the string input func_type. To use the functions of the hyperbolic module, there are three ways of importing modules from a library which are listed below together on how to use them in the client code. It also gives a reason of using a particular import stype (although this can sometime be up to a programmers preferred coding style): / Skryf nou kliëntprograme hyper_client.py wat twee commen-lyn parameters func_type en value neem en die berekende hiperboliese waarde van value uitdruk gebaseer op die string func_type. Om die funksies van die hiperboliese module te gebruik, is daar drie maniere om modules vanaf 'n biblioteek in te voer wat hieronder saam gelys word oor hoe om dit in die kliëntkode te gebruik. Dit gee ook 'n rede om 'n spesifieke invoertipe te gebruik (alhoewel dit soms tot 'n programmeerders se voorkeur-koderingstyl kan wees):

from hyperbolic import cosh

# usage: cosh(x)

# reason: "If you are only planning on using cosh, then there is no need to import the other methods"

from hyperbolic import *

# usage: cosh(x)

# reason: "If you are using most of the module's methods, this will be the cleaner import statement,

# however, it is often considered unclear and bad style."

import hyperbolic

# usage: hyperbolic.cosh(x)

# reason: "This is an absolute import and considered by most to be the cleanest and best import style."

The output should look as follows: / 'n Korrekte implementering sal die volgende resultate lewer:

$ python hyper_client.py cosh 0.9

1.4330863854487745

$ python hyper_client.py sinh 0.9

1.0265167257081753

$ python hyper_client.py sinc 0.9

Hyperbolic function name not recognised.
More questions like this

Want instant access to all verified answers on stemlearn.sun.ac.za?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome