Python - Numbers
An integer, commonly abbreviated to int, is a whole number (positive, negative, or zero). So 7 , 0 , -11 , 2 , and 5 are integers. 3.14159, 0.0001, 11.11111, and even 2.0 are not integers, they are floats in Python.
Types of data stored in numbers. They are the types of data that are reasonable, which means that the type of data changes in the new content provided.
the number of objects created when the value is recorded. For example -
var1 = 1 var2 = 10
You can also delete the product reference through the product. The word phrase came from -
del var1[,var2[,var3[....,varN]]]]
You can delete one item or a few items using the instructions. For example -
del var del var_a, var_b
Python supports four different types of numbers -
• int (signals) - refer only to studies or calculations, modifiers or denominations, which do not have decimals.
• long (deep and tall) - also known as length is a measure of unlimited sizes and writes the repetition and repetition of the capital or the lower case L.
• Movement (actual value) - also called floats, representing the realm of the same part and the fraction part of the fraction. The rain may also be a science textbook, E and E showing the power of 10 (2.5e2 = 2.5 x 102 = 250).
• Strong types (complex numbers) - are in the + + bj format, where a and b is running J (or j) stands for the square -1 (which is a fiction number). The actual number is, and b is a mental part. Combined numbers are not used in the Python program.
For example
int
|
long
|
float
|
complex
|
10
|
51924361L
|
0.0
|
3.14j
|
100
|
-0x19323L
|
15.20
|
45.j
|
-786
|
0122L
|
-21.9
|
9.322e-36j
|
080
|
0xDEFABCECBDAECBFBAEL
|
32.3+e18
|
.876j
|
-0490
|
535633629843L
|
-90.
|
-.6545+0J
|
-0x260
|
-052318172735L
|
-32.54e100
|
3e+26J
|
0x69
|
-4721885298529L
|
70.2-E12
|
4.53e-7j
|
Here are some examples
• Python allows you to use the small L with a long, but it is recommended that you only use LargeC L to prevent the frustration of the number 1. Showing the Python study with the L.
• The gender composition comprising ordered real numbers called "point BJ + ', which is a serious mental and b is part of the construction of a series.
price change price
Python's changes to the internal expression number that contains a combination of types of general assessment types. But sometimes, you must force the number that can be downloaded in any form to meet the requirements of the worker or occupational boundaries.
• Type int (x) to convert x arrows.
• Type x (x) x to lengthen the length.
• The float (x) x changes to the number numbers.
• Type of combination (x) to change the fractional number of the actual part and the peripheral part of zero.
• Combined form (x, y) to change x and y to evaluate the combination of the real part and the partial partition. x and y is a sentence of numbers
Mathematical functions
Python includes the following functions to calculate mathematical calculations.
Sr.No. | Function & Returns ( description ) |
---|---|
1 | abs(x)
The absolute value of x: the (positive) distance between x and zero.
|
2 | ceil(x)
The ceiling of x: the smallest integer not less than x
|
3 | cmp(x, y)
-1 if x < y, 0 if x == y, or 1 if x > y
|
4 | exp(x)
The exponential of x: ex
|
5 | fabs(x)
The absolute value of x.
|
6 | floor(x)
The floor of x: the largest integer not greater than x
|
7 | log(x)
The natural logarithm of x, for x> 0
|
8 | log10(x)
The base-10 logarithm of x for x> 0.
|
9 | max(x1, x2,...)
The largest of its arguments: the value closest to positive infinity
|
10 | min(x1, x2,...)
The smallest of its arguments: the value closest to negative infinity
|
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)
The value of 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)
The square root of x for x > 0
|
Random Number Function
Special numbers are used for games, simulation, testing, safety, and special requests. Python includes the following functions which are mostly used.
Sr.No. | Function & Description |
---|---|
1 | choice(seq)
A random item from a list, tuple, or string.
|
2 | randrange ([start,] stop [,step])
A randomly selected element from range(start, stop, step)
|
3 | random()
A random float r, such that 0 is less than or equal to r and r is less than 1
|
4 | seed([x])
Sets the integer starting value used in generating random numbers. Call this function before calling any other random module function. Returns None.
|
5 | shuffle(lst)
Randomizes the items of a list in place. Returns None.
|
6 | uniform(x, y)
A random float r, such that x is less than or equal to r and r is less than y
|
Trigonometric function
Python includes the following jobs to make trigonometry calculations.
Sr.No. | Function & Description |
---|---|
1 | acos(x)
Return the arc cosine of x, in radians.
|
2 | asin(x)
Return the arc sine of x, in radians.
|
3 | atan(x)
Return the arc tangent of x, in radians.
|
4 | atan2(y, x)
Return atan(y / x), in radians.
|
5 | cos(x)
Return the cosine of x radians.
|
6 | hypot(x, y)
Return the Euclidean norm, sqrt(x*x + y*y).
|
7 | sin(x)
Return the sine of x radians.
|
8 | tan(x)
Return the tangent of x radians.
|
9 | degrees(x)
Converts angle x from radians to degrees.
|
10 | radians(x)
Converts angle x from degrees to radians.
|
Mathematical Constants:
The module also defines two continuous accounts -
Sr.No. | Constants & Description |
---|---|
1 |
pi
The mathematical constant pi.
|
2 |
e
The mathematical constant e.
|
Comments
Post a Comment