A2 Python Numbers
A2 Python Numbers
A2 Python Numbers
Example:
var1=1
var2=10
You can also delete the reference to a number object by using the del statement.
Syntax:
del var1[,var2[,var3[………….,varN]]]]
You can delete a single object or multiple objects by using the del statement.
Example:
del var
int (signed integers) − They are often called just integers or ints, are positive or
negative whole numbers with no decimal point.
float (floating point real values) − Also called floats, they represent real numbers and
are written with a decimal point dividing the integer and fractional parts. Floats may
also be in scientific notation, with E or e indicating the power of 10 (2.5e2 = 2.5 x 10 2 =
250).
complex (complex numbers) − are of the form a + bJ, where a and b are floats and J (or
j) represents the square root of -1 (which is an imaginary number). The real part of the
number is a, and the imaginary part is b. Complex numbers are not used much in
Python programming.
Example:
A complex number consists of an ordered pair of real floating point numbers denoted by a + bj,
where a is the real part and b is the imaginary part of the complex number.
Mathematical Functions
Python includes following functions that perform mathematical calculations.
1 abs(x)
2 fabs(x)
3 exp(x)
The exponential of x: ex
5 ceil(x)
7 log(x)
8 log10(x)
9 max(x1, x2,...)
10 min(x1, x2,...)
11 modf(x)
The fractional and integer parts of x in a two-item tuple. Both parts have the same sign
as x. The integer part is returned as a float.
12 pow(x, y)
13 round(x [,n])
x rounded to n digits from the decimal point. Python rounds away from zero as a tie-
breaker: round(0.5) is 1.0 and round(-0.5) is -1.0.
14 sqrt(x)
1 choice(seq)
3 random()
A random float r, such that 0 is less than or equal to r and r is less than 1
4 shuffle(lst)
5 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
Python includes following functions that perform trigonometric calculations.
1 acos(x)
2 asin(x)
3 atan(x)
5 cos(x)
6 hypot(x, y)
7 sin(x)
8 tan(x)
9 degrees(x)
10 radians(x)
Mathematical Constants
The module also defines two mathematical constants −
1
pi
2
e
The mathematical constant e.