Get the App
SLTechnology News&Howtos  ›  Development  › 

What exactly does the Python number type mean?

Shulou Source: shulou.com Published: 2022-06-02 09:05:14 10月04日 Update

This article introduces the relevant knowledge of "what is the specific meaning of Python digital type". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Meaning

The Python numeric type is immutable, which means that changing the value of the number produces a new object.

Change

The following is an example of modifying and deleting numeric types.

> id (a) 3629968 > id (a) 3629956 > del a > id (a) Traceback (most recent call last): File ", line 1, in NameError: name'a'is not defined >

Python numeric type category

Number types in Python: integer, long integer, Boolean, double-precision floating-point, decimal floating-point, and plural.

1) Integer

A) Boolean type: an integer with only two values.

> a=True > int (a) 1 > > a=False > int (a) 0 > bool (1) True > bool (True) True > bool ('1') True > bool ('0') True > bool (0) False > bool ('') False > bool ([]) False > > Azo1 > > Baima > > b True > > True,FalseFalse=False,True > bool (True) False > > bool (False) True

B) Integers and long integers

After Python 2.2, integers and long integers can be considered the same thing.

> 1000000000000000000000000000000000000000000000000000000000L > 100000000000 >

2) double precision floating point number

Detailed explanation of basic Application Syntax of Python Construction list

Python realizes the sharing of basic operation modes of ini file operation.

Interpretation of Application methods related to tab File manipulation realized by Python

Use Python recursion to deal with files

Analysis of simple examples of Python file operation

Similar to double in C #.

3) plural

The complex number in the Python number type consists of the real part and the imaginary part: real+imagj.

Negative attribute:

Num.real the real part of the plural

Num num.imag the imaginary part of the complex number

Num.conjugate () returns the conjugate complex of the complex number.

> id (a) 19911528 > > id (b) 19911600 > > a.real 19911600 > > a.imag 3.0 > a.conjugate

4) Decimal floating point number

Decimal > from decimal import Decimal > Decimal ("0.1") * Decimal ("3.1415926") Decimal ("0.31415926") "what is the specific meaning of the Python number type" is introduced here, thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Type number plural file meaning content decimal Boolean way more floating point point knowledge precision part decimal application practical learned next Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi macOS Microsoft Huawei Shulou Information