Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What exactly does the Python number type mean?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report