Number
Numeric data types store numeric values. Number objects are created when you assign a value to them. For example:
var1 = 1
var2 = 10
Python supports four different numerical types:
- int (signed integers) : 10, 5464646546
- float (floating point real values) : 3.14546464646
- complex (complex numbers) : 9.322e+26j
Mathematical Functions
- abs(x)
- ceil(x)
- cmp(x, y) : -1 if x < y, 0 if x == y, or 1 if x > y
- exp(x)
- fabs(x) : The absolute value of x.
- floor(x)
- log(x) : The natural logarithm of x, for x> 0
- log10(x) : The base-10 logarithm of x for x> 0
- max(x1, x2,...)
- min(x1, x2,...)
- modf(x) : The fractional and integer parts of x in a two-item tuple.
- pow(x, y) : The value of x**y.
- round(x [,n])
- sqrt(x)
Random Number Functions
Random numbers are used for games, simulations, testing, security, and privacy applications. Python includes following functions that are commonly used.
- choice(seq)
- randrange ([start,] stop [,step])
- random()
- seed([x]) : Sets the integer starting value used in generating random numbers. Call this - function before calling any other random module function. Returns None.
- shuffle(lst)
- uniform(x, y) : A random float r, such that x is less than or equal to r and r is less than y
Trigonometric Functions
- acos(x)
- asin(x)
- atan(x)
- atan2(y, x)
- cos(x)
- hypot(x, y)
- sin(x)
- tan(x)
- degrees(x)
- radians(x)
Mathematical Constants
- pi : The mathematical constant pi
- e : The mathematical constant e