The numbers and functions python random number function

A digital function: To import the package Math
  . 1, ABS (X): Returns the absolute value (absolute directed to find an integer). fabs (x) is absolutely required for in floating point.
  2, ceil (x) rounded up, as math.ceil (4.1) 5 returns. floor (x) Returns the integer rounded, as math.floor (4.9) returns 4.
  3, cmp (x, y) : If x <y -1, returns 0 if x == y, if x> y returned. (Python 3 has been discarded, the use of (x> y) - (x <y) replaced.)
  . 4, exp (x): Returns the e power of x.
  5, log10 (x): returns the logarithm to the base 10 of x, such math.log10 (100) returns 2.0. If a log (x), then is to see how many parameters: a parameter such as: math.log (math.e) return 1.0, the default base-E; The two parameters: math.log (100,10) Returns 2.0. The second parameter is the default base number.
  6, max () / min ( ) returns the minimum and maximum values of the given parameter, the parameter may be a sequence.
  7, modf (x) returns the integer portion and the fractional portion of x, the same value and sign of the two portions x, integer part expressed in floating-point.
  8, pow (x, y) : x ** y operator demand value.
  9, round (x [, n ]): Returns the value of the floating point number x rounded, given as the value of n represents the rounded to the decimal point.
  10, sqrt (x) returns the square root of the number x.
Second, the random number functions:
  . 1, Choice (SEQ) from a sequence of elements in a randomly selected element, such random.choice (range (10)), from 0 to 9, a randomly selected integer.
  2, randrange ([start,] stop [, step]), acquiring a random number within a specified range from the specified base set in increments, the default value is 1 cardinality.
  3, random (): a real number generated at random, it is in the [0,1) range.
  4, seed ([x]) : to change the random number generator seed seed. If you do not understand the principle, you do not have to go to special set seed, Python will help you choose the seed.
  5, shuffle (list): All the elements randomly ordered sequence.
  6, uniform (x, y) : a real number generated at random, it is within [x, y] range.

Guess you like

Origin www.cnblogs.com/yangrongkuan/p/12067091.html