Page 247 - Computer Science V2.0 Class 11
P. 247

3.  math.sqrt(num)
                    Function sqrt() takes a positive integer or floating point number as the input and returns the square root of the
                    number. For instance, the following function call returns the square root of 25.
                  >>> math.sqrt(25)
                      5.0
                 4.  math.pow(num1, num2)
                      Function pow() takes two integers or floating point numbers as the input and returns the num1 raised to the
                                                                                  3
                    power of num2. For instance, the following function call computes 2 .
                  >>> math.pow(2, 3)
                      8.0
                 5.  math.factorial(num)
                      Function factorial() takes a positive integer as an input and returns the factorial of the number. For instance,
                    the following function call returns the factorial of the number 5.

                  >>> math.factorial(5)
                      120
                 6.  math.gcd(num1, num2)
                      Function gcd() takes two integers as an input and returns the greatest common divisor of num1 and num2.
                    For instance, the following function call returns 8 as the greatest common divisor of 16 and 24, both being divisible
                    by 8.
                  >>> math.gcd(16,24)
                      8
                 7.  math.sin(num)
                      Function sin() takes a positive integer or floating point number in radians as an input and returns its arc sine
                    value. For instance, the following function call returns the sine value of pi/2 (3.14/2 in radians) as the output:

                  >>> math.sin(math.pi/2)
                      1.0
                 8.  math.cos(num)
                      Function cos() takes a positive integer or floating point number in radians as an input and returns its cosine
                    value. For instance, the following function call returns the cosine value of 1.0 (radians) as the output:

                  >>> math.cos(0.0)
                      1.0



                         Give the function call that would yield cosine of an angle of 60°? Recall that π radians = 180°.




                 9.  math.tan(num)
                      Function tan() takes a positive integer or floating point number in radians as an input and returns its arc tan
                    value. For instance, the following function call returns the tangent value of pi/4 (radians) as the output:
                  >>> math.tan(math.pi/4)
                      0.9999999999999999
                 The math module built-in functions are summarized in the following table:

                                                   Description of
                  S. No.       Function                                   Return Value(s)             Examples
                                                    Argument(s)
                    1    math.ceil(num)       Integer or floating point   Ceiling (highest closest  >>> math.ceil(13.3)
                                              number                   integer) value of num      14

                                                                                             >>> math.ceil(-15.4)
                                                                                                 -15
                                                                                                 -16<-15.4<=-15

                                                                                                           Modules    233
   242   243   244   245   246   247   248   249   250   251   252