Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Python | what are the number types of Python?

Shulou Source: shulou.com Published: 2022-06-02 03:16:48 09月27日 Update

This article is to share with you about the digital types of Python | Python. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Without saying much, let's take a look at it with the editor.

Numeric type of Python

The numeric type Number in the Python program is used to store values. At first, Python3 only supports int, float, bool and complex, and removes the long type from Python2. I'll describe the four numeric types in python3 in detail below.

Integer (int)

Integers (int) are integers and do not contain decimal points. In Python, you can also use 0 + "base standard" + numbers to represent different base numbers.

For example, the number of OBO + is octal.

The number of 0,0xapple X+ is hexadecimal.

The number of 0binary b _ b _ B+ is binary

A decimal system without a decimal character

The following demonstrates the mathematical operations related to plastic surgery

Floating point (float)

Floating point is a combination of integers and decimals, such as 12.5 is a floating point number. Floating-point types can also be represented by scientific counting, such as 125=1.25e2. Integers and floating-point numbers are stored in different ways inside the computer, the operation of integers is absolutely accurate, but the operation of floating-point numbers may have rounding errors.

Boolean (Boolean)

Boolean is a little different from the above two types in that it is a simple type that represents logical values, that is, right and wrong, and the logical relationship between right and wrong. Boolean values can only be either true or false. In python, the only Boolean values are True and False, which are used to represent logical "true" and "false". The values are 1 and 0, respectively.

Here are a few simple examples of Boolean usage

Plural (complex)

The plural type (complex) consists of a real part and an imaginary part, and can be represented by complex (amenb) or a+bj. Where the real part an and the imaginary part b are floating point.

These are the number types of Python | Python. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Tags: Number type Boolean floating point integer part different that is binary logic operation two plural decimal more point knowledge article storage practical Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno MariaDB Docker Redmi Microsoft