Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What is python number type?
What is python number type?
Python number type: 1, integer, usually called integer or integer, which can be positive integer or negative integer without decimal point; 2. Floating-point type consists of integer part and decimal part; 3. Boolean type; 4. Complex number consists of real part and imaginary part.

Related free study recommendation: python video tutorial

Python number type:

① Integer:

Usually called integer or integer, it can be a positive integer or a negative integer without decimal point. Python3 integer has no size limit and can be used as a long type, but in fact, due to the limited memory of the machine, the integer we use cannot be infinite.

Four manifestations of integers:

Binary: starts with "0b". For example,' 0b1101'means 27 in10.

Octal: starts with "0o". For example, "0o33" means 27 in 10.

10 radix: displayed normally.

16 base: starts with "0x". For example, "0x 1b" means 27 with cardinality of 10.

Convert each number (built-in function):

Bin(i): Convert I to binary, starting with "0b".

Oct(i): Convert I to octal, starting with "0o".

Int(i): Convert I to 10, and display normally.

Hex(i): Convert I to 16, starting with "0x".

② floating point number:

Floating-point type consists of integer part and decimal part, and floating-point type can also be expressed by scientific notation (2.5e2 = 2.5 x 102 = 250).

③ Boolean type:

All standard objects can be used for Boolean testing, and objects of the same type can be compared in size. Every object is born with a true or false Boolean value. An empty object, any number with a value of zero, or the Boolean value None of a Null object is False. In Python3, True= 1 and False=0, which can be operated by numbers.

The Boolean values of the following objects are false:

None; Fake; 0 (integer), 0.0 (floating point); 0L (long shaping); 0.0+0.0j (complex number); (empty string); [] (empty list); () (empty tuple); {} (empty dictionary).

Boolean values of objects whose values are not any of the above values are true, such as non-null, non-zero, etc. User-created class instances are defined by nonzero (_nonzeor_ ()) or length (_len_ ()), and their Boolean values are False.

④ Complex number:

Complex number consists of real part and imaginary part, which can be expressed by a+bj or complex number (a, b). The real part A and imaginary part B of a complex number are both floating-point types.