Min menu

Pages

math model functions in Python

Python  functionceil()

its definition

Returns the integer greater or equal to the number we pass to it in the place of the parameter x.

Ceil() function Define it Returns the larger integer or equal to the number we pass to it in the place of the parameter x.

built

                  ceil(x)
	  

parameters

xA number that has no specific type.


Return value

Returns the integer greater or equal to the number we pass to it in the place of the parameter x.


Example

Test.py
                    # ceil() which contains the math function here we called the module
		  import math
	  
		  # ceil() Here we have shown the integer greater or equal to 5.0 returned by the function
		  print('math.ceil(5.0) =', math.ceil(5.0))
	  
		  # ceil() Here we have shown the integer greater or equal to 5.3 returned by the function
		  print('math.ceil(5.3) =', math.ceil(5.3))
	  
		  # ceil() Here we have shown the integer greater or equal to 5.7 returned by the function
		  print('math.ceil(5.7) =', math.ceil(5.7))
	

We will get the following result when running.

math.ceil(5.0) = 5
math.ceil(5.3) = 6
math.ceil(5.7) = 6

Python numbers  functionfloor()

its definition

Returns the integer smaller or equal to the number we pass to it in the place of the parameter x.


built

                  floor(x)
	  

parameters

xA number that has no specific type.


Return value

Returns the integer smaller or equal to the number we pass to it in the place of the parameter x.


Example

Test.py
                    # floor() which contains the math function here we called the module
		  import math
	  
		  # floor() Here we have shown the integer smaller or equal to 5.0 returned by the function
		  print('math.floor(5.0) =', math.floor(5.0))
	  
		  # floor() Here we have shown the integer smaller or equal to 5.3 returned by the function
		  print('math.floor(5.3) =', math.floor(5.3))
	  
		  # floor() Here we have shown the integer smaller or equal to 5.7 returned by the function
		  print('math.floor(5.7) =', math.floor(5.7))
	

We will get the following result when running.

math.floor(5.0) = 5
math.floor(5.3) = 5
math.floor(5.7) = 5

Python numbers  functionpow()

its definition

Returns the result of doubling the value of the number we pass to it in the place of the parameter, xa multiple of the value of the parameter y.
powword shortcutpower.


built

                  pow(x, y)
	  

parameters

  • xA number that has no specific type.

  • yA number that has no specific type.


Return value

Returns the result of doubling the value of the number we pass to it in the place of the parameter , xa multiple of the value of the parameter y, returns it as float.


Example

Test.py
                    # pow() which contains the math function here we called the module
		  import math
	  
		  # pow() Here we have shown the result of multiplying the number 5 twice returned by the function
		  print('pow(5, 2) =', math.pow(5, 2))
	

We will get the following result when running.

pow(5, 2) = 25.0

Python numbers  functionsqrt()

its definition

Returns the value of the squared islands(square root)For the number that we pass it has the place of the parameter x.

Python numbers sqrt () function Define it The square root value of the number we pass to it returns the place of the parameter x.

built

                  sqrt(x)
	  

parameters

xA number that has no specific type.


Return value

Returns the squared island value of the number we pass to it in the place of the parameter x, returns it as float.


Example

Test.py
                    # sqrt() which contains the math function here we called the module
		  import math
	  
		  # sqrt() Here we have shown the result of the squared island of the number 25 returned by the function
		  print('sqrt(25) =', math.sqrt(25))
	

We will get the following result when running.

sqrt(25) = 5.0

Python  functionexp()

its definition

Returns the value of .exponentialThe number that we pass has the place of the parameter x, which is equal to e**x.
In mathematics, the symbol for . isexponentialby lettereIts value is 2.718281828459045 and we can get it from the module mathlike this math.e.


built

                  exp(x)
	  

parameters

xA number that has no specific type.


Return value

Returns the value of .exponentialFor the number we put it in the place of the parameter x, which is equal to the value of a emultiple of x.


Example

Test.py
                    # exp() which contains the math function here we called the module
		  import math
	  
		  # exp() for the number 5 returned by the exponential function here we have shown the value of
		  print('math.exp(5) =', math.exp(5))
	

We will get the following result when running.

math.exp(5) = 148.4131591025766

Python numbers  functionlog()

its definition

Returns the value of .LogarithmThe number that we pass has the place of the parameter xwith the possibility of specifying the type of unit for this number.
denoted bylogIn mathematics.


built

                  log(x[, base])
	  

parameters

  • xA number that has no specific type.

  • baseThis is an optional parameter, i.e. you are not forced to pass the value in its place, which is an integer representing the unit of the parameter x.
    If you do not pass the place value of this parameter, it will be considered that you have passed the eplace value.


Return value

Returns the value of .LogarithmFor the number that we pass it has the place of the parameter x.


Example

Test.py
                    # log() which contains the math function here we called the module
		  import math
	  
		  # log() returned by the function (e equals base of 5) considering that the logarithm here we displayed the value of
		  print('log(5) =', math.log(5))
	  
		  # log() returned by the function ( log base e of the number 5) with the fact that we are using Logarithm here we displayed the value of
		  print('log(5, e) =', math.log(5, math.e))
	  
		  # log() returned by the function ( log base 2 for the number 5) with the fact that we are using Logarithm here we displayed the value of
		  print('log(5, 2) =', math.log(5, 2))
	  
		  # log() returned by the function ( log base 10 for the number 5) with the fact that we are using Logarithm here we displayed the value of
		  print('log(5, 10) =', math.log(5, 10))
	

We will get the following result when running.

log(5) = 1.6094379124341003
log(5, e) = 1.6094379124341003
log(5, 2) = 2.321928094887362
log(5, 10) = 0.6989700043360187

Python  functionlog2()

its definition

Returns the value of .Logarithm Base 2For the number that we pass it has the place of the parameter x.
denoted bylog2In mathematics.

This function is a substitute for the function log(x, 2).

Log2() function Define it Logarithm Base 2 

returns the number we pass to it, where the parameter is x. It is denoted by log2 in mathematics. This function is an alternative to the log (x, 2) function. Built

built

                  log2(x)
	  

parameters

xA number that has no specific type.


Return value

Returns the value of .Logarithm Base 2For the number that we pass it has the place of the parameter x.


Example

Test.py
                    # log2() which contains the math function here we called the module
		  import math
	  
		  # log2() of the number 5 returned by the Logarithm Base 2 function here we show the value of
		  print('log2(5) =', math.log2(5))
	

We will get the following result when running.

log2(5) = 2.321928094887362

Python numbers  functionlog10()

its definition

Returns the value of .Logarithm Base 10For the number that we pass it has the place of the parameter x.
denoted bylog10In mathematics.

This function is a substitute for the function log(x, 10).

built

                  log10(x)
	  

parameters

xA number that has no specific type.


Return value

Returns the value of .Logarithm Base 10For the number that we pass it has the place of the parameter x.


Example

Test.py
                    # log10() which contains the math function here we called the module
		  import math
	  
		  # log10() of the number 5 returned by the Logarithm Base 10 function. Here we display the value of
		  print('log10(5) =', math.log10(5))
	

We will get the following result when running.

log10(5) = 0.6989700043360189

Python  functionsin()

its definition

Returns the value of .sinFor the number that we pass it has the place of the parameter x.


built

                  sin(x)
	  

parameters

xA number that has no specific type.


Return value

Returns the value of .sinFor the number we pass to it in the place of the parameter x, you return it as float.


Example

Test.py
                    # sin() which contains the math function here we called the module
		  import math
	  
		  # sin() of the number 25 returned by the sine function here we have shown the result of
		  print('sin(25) =', math.sin(25))
	

We will get the following result when running.

sin(25) = -0.13235175009777303

Python numbers  functioncos()

its definition

Returns the value of .cosineFor the number that we pass it has the place of the parameter x.


built

                  cos(x)
	  

parameters

xA number that has no specific type.


Return value

Returns the value of .cosineFor the number we pass to it in the place of the parameter x, you return it as float.


Example

Test.py
                    # cos() which contains the math function here we called the module
		  import math
	  
		  # cos() of the number 25 returned by the cosine function here we have shown the result of
		  print('cos(25) =', math.cos(25))
	

We will get the following result when running.

cos(25) = 0.9912028118634736

Python  functiontan()

its definition

Returns the value of .TangentFor the number that we pass it has the place of the parameter x.

Python tan () function Define it The tangent returns the number we pass to it, the place of the parameter x. Built

built

                  tan(x)
	  

parameters

xA number that has no specific type.


Return value

Returns the value of .TangentFor the number we pass to it in the place of the parameter x, you return it as float.


Example

Test.py
                    # tan() which contains the math function here we called the module
		  import math
	  
		  # tan() for the number 25 returned by the tangent function here we have shown the result of
		  print('tan(25) =', math.tan(25))
	

We will get the following result when running.

tan(25) = -0.13352640702153587

Python numbers  functionasin()

its definition

Returns the value of .arc sinFor the number that we pass it has the place of the parameter x.
The value we set must be between 1- and 1 .


built

                  asin(x)
	  

parameters

xA number that has no specific type.


Return value

Returns the value of .arc sinFor the number we pass to it in the place of the parameter x, you return it as float.


Example

Test.py
                    # asin() which contains the math function here we called the module
		  import math
	  
		  # asin() for the number 0.5 returned by the arc sine function here we have shown the result of
		  print('asin(0.5) =', math.asin(0.5))
	

We will get the following result when running.

asin(0.5) = -0.13352640702153587

Python  functionacos()

its definition

Returns the value of .arc cosineFor the number that we pass it has the place of the parameter x.
The value we set must be between 1- and 1 .


built

                  acos(x)
	  

parameters

xA number that has no specific type.


Return value

Returns the value of .arc cosineFor the number we pass to it in the place of the parameter x, you return it as float.


Example

Test.py
                    # acos() which contains the math function here we called the module
		  import math
	  
		  # acos() for the number 0.5 returned by the arc cosine function here we have shown the result of
		  print('acos(0.5) =', math.acos(0.5))
	

We will get the following result when running.

acos(0.5) = 1.0471975511965979

Python  functionatan()

its definition

Returns the value of .arc tangentFor the number that we pass it has the place of the parameter x.


built

                  atan(x)
	  

parameters

xA number that has no specific type.


Return value

Returns the value of .arc tangentFor the number we pass to it in the place of the parameter x, you return it as float.


Example

Test.py
                    # atan() which contains the math function here we called the module
		  import math
	  
		  # atan() for the number 40.5 returned by the arc tangent function here we display the result of
		  print('atan(40.5) =', math.atan(40.5))
	

We will get the following result when running.

atan(40.5) = 1.5461099847392972

Python  functiondegrees()

its definition

Converts the value of the number we pass into the place of the parameter xtoDegrees.

Python function degrees () Define it The transformation of the number we pass has the place of the parameter x of Degrees.

built

                  degrees(x)
	  

parameters

xA number that has no specific type.


Return value

Returns the value of .DegreesFor the number we pass to it in the place of the parameter x, you return it as float.


Example

Test.py
                    # degrees() which contains the math function here we called the module
		  import math
	  
		  # degrees() for the number 15 returned by the Degrees function Here we have shown the result of
		  print('degrees(15) =', math.degrees(15))
	

We will get the following result when running.

degrees(15) = 859.4366926962348

Python  functionradians()

its definition

Converts the value of the number we pass into the place of the parameter xtoRadians.


built

                  radians(x)
	  

parameters

xA number that has no specific type.


Return value

Returns the value of .RadiansFor the number we pass to it in the place of the parameter x, you return it as float.


Example

Test.py
                    # radians() which contains the math function here we called the module
		  import math
	  
		  # radians() for the number 15 returned by the radians function Here we have shown the result of the
		  print('radians(15) =', math.radians(15))
	

We will get the following result when running.

radians(15) = 0.2617993877991494

Python  functiongcd()

its definition

Returns an integer representing the greatest common divisor(Greatest Common Divisor)Between the two numbers we pass it has the place of the parameters xand y.

Python gcd() function Define it Returns an integer that represents the Greatest Common Divisor between the two numbers we pass for it in place of the parameters x and y.

built

                  gcd(x, y)
	  

parameters

  • xis an integer.

  • yis an integer.


Return value

Returns an integer representing the greatest common divisor between the two numbers we pass to it in place of the parameters xand y.


Example

Test.py
                    # gcd() which contains the math function here we called the module
		  import math
	  
		  # gcd() Here we have shown the greatest common number between 36 and 45 returned by the function
		  print('gcd(36, 45) =', math.gcd(36, 45))
	

We will get the following result when running.

gcd(36, 45) = 9