Python Coding And Programming: Start to learn the hard core of computer programming, data analysis and coding project in python by Learn Michael

Python Coding And Programming: Start to learn the hard core of computer programming, data analysis and coding project in python by Learn Michael

Author:Learn, Michael [Learn, Michael]
Language: eng
Format: epub
Published: 2019-10-27T16:00:00+00:00


Math functions

One group of functions that is frequently required by basic math functions like log, sin, cos, sqrt. All of these can be used by importing the math library into the program. Once the math library is imported into the program, it becomes very easy to use complex mathematical operations and solve complicated equations. Here is a demonstration of some of the basic math functions using the dot notation.

>>>import math

>>>math.sqrt(2)/2.0

0.70710678

The trigonometric functions of sin, cos, tan etc can be performed using trigonometric math operations. These functions take radians in the arguments and give the results.

>>> radians = 0.7

>>> height = math.sin(radians)

If we have degrees, we can first convert them into radians by dividing it with 360 and multiplying it with twice of pi. The value of pi can be achieved by writing math.pi. Now pi is a variable and not a function so it is written without the () brackets.

>>> degrees = 45

>>>radians= degrees/360 *2*math.pi

>>>math.sin(radians)

0.70710678

There are a number of other functions available in the math library. We can explore it through learnPython.com and other web resources.

The names of the built in functions are also reserved and while naming variables we should avoid using them as variable names.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.