Page 2 - Lesson Note-Python Modules and Sorting
P. 2

math Module






















               sin, cos and tan takes input in radians and radians function of math converts degree to it’s
               equivalent radians.













               Predefined pi and e











               random Module

               random()
                   •   return the next random floating point number in the range
                       [0.0, 1.0) i.e. 0<=N<1

               randint(lower limit, upper limit)
                   •   returns a random integer N such that lower_limit<=N<=upper_limit
                   •   The randint(a,b) function accepts two integer parameters, and both are required.
                   •   Both parameters should be integer

               randrange(start,  stop [,  step])
                   •   Returns a random integer in the range (start, stop, step) as per range function
                   •   The step is a difference between each number in the sequence. The step is optional, and the
                       default value of the step is 1, start is also optional and if no start it returns a random number
                       N such that 0<=N<stop
                   •   All parameters should be integer
   1   2   3   4