Home  >  Article  >  Backend Development  >  What is a Python Number? What are the Python number types?

What is a Python Number? What are the Python number types?

Tomorin
TomorinOriginal
2018-08-14 10:21:063216browse

To know Python data types, First we have to understand what Python Number (number) is. The content of this chapter is an introduction. Python Number is different from Mathematics concept. Python number type is used to store numerical values. Data type is not allowed to be changed. This means that if you change the value of the Number data type, the memory space will be reallocated.

So what is Python Number? The following instance of a Number object will be created when a variable is assigned a value:

var1 = 1
var2 = 10

You can also use the del statement to delete some Number object references.

The syntax of the del statement is:

del var1[,var2[,var3[....,varN]]]]

You can delete single or multiple objects by using the del statement, for example:

del var
del var_a, var_b

The first line It means to use the del statement to delete the variable system named var

The second line means to delete the two small categories a and b in the var system.

Through the introduction to Python Number, we can learn what the Python number type is:

supports four different Python Data type

1.Integer type (Int) - usually It is called an integer or an integer, a positive or negative integer without a decimal point.

2.Long integers - Integer of infinite size, the last integer is an uppercase or lowercase L.

3.Floating point type (floating point real values) - The floating point type consists of an integer part and a decimal part. The floating point type can also be expressed using scientific notation (2.5e2 = 2.5 x 102 = 250)

4.Complex numbers (complex numbers) - Complex numbers are composed of real parts and imaginary parts, and can be represented by a bj, or complex(a,b), complex numbers The real part a and the imaginary part b are both floating point types.

##intlogfloatcomplex1051924361L0.03.14j100-0x19323L15.2045.j-7860122L-21.99.322e-36j##080-0490-0x2600x691. Long whole You can also use a lowercase "L" for the type, but it is recommended that you use an uppercase "L" to avoid confusion with the number "1". Python uses "L" to display long integers.







0xDEFABCECBDAECBFBAEl 32.3 e18 .876j
535633629843L
-90.
-.6545 0J
-052318172735L -32.54e100
3e 26J

-4721885298529L 70.2-E12 4.53e-7j

2.Python also supports complex numbers. Complex numbers are composed of real parts and imaginary parts. They can be represented by a bj, or complex(a,b). The real part a and the imaginary part b of the complex number are both floating point types.

For more related knowledge, please visit the

Python tutorial

column on the php Chinese website.


The above is the detailed content of What is a Python Number? What are the Python number types?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn