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

Tomorin
Release: 2018-08-14 10:21:06
Original
3150 people have browsed it

To knowPython data types,First we have to understand whatPython Number (number) is.The content of this chapter is an introduction.Python Number is different fromMathematicsconcept. Python number typeis used to store numerical values.Data typeis not allowed to be changed. This means that if you change the value of the Number data type, the memory spacewill be reallocated.

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

var1 = 1 var2 = 10
Copy after login

You can also use thedel statementto delete someNumberobject references.

The syntax of the del statement is:

del var1[,var2[,var3[....,varN]]]]
Copy after login

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

del var del var_a, var_b
Copy after login

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 toPython Number, we can learn what thePython number type is:

supports four differentPythonData 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.

##int log float complex 10 51924361L 0.0 3.14j 100 -0x19323L 15.20 45.j -786 0122L -21.9 9.322e-36j ##080 -0490 -0x260 0x69 1. 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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!