Basic data type---number

boolean (bool)

The bool type has only two values: True and False
The reason why bool values ​​are classified as numbers is because we are also used to using 1 for True and 0 for False.

Integer

Integers in Python belong to the int type, which is represented by decimal by default. In addition, binary, octal, and hexadecimal representations are also supported.
base conversion
Numbers in python are still decimal by default. Some methods are also provided to help us do the conversion. For example, when converting from hexadecimal to binary, use the bin method, and add '0b' in front of the conversion result to indicate that it is a binary book.

floating point

A floating-point number is a numerical representation of a number that belongs to a certain subset of rational numbers , and is used in computers to approximate any real number . Specifically, this real number is obtained by multiplying an integer or fixed-point number (ie, the mantissa ) by an integer power of a base (usually 2 in computers), which is similar to base 10 scientific notation .
Why is it called float floating point?
浮点数也就是小数,之所以称为浮点数,是因为按照科学记数法表示时,
一个浮点数的小数点位置是可变的,比如,
1.23*109和12.3*108是相等的。
浮点数可以用数学写法,如1.23,3.14,-9.01,等等。但是对于很大或很小的浮点数,就必须用科学计数法表示,把10用e替代:
1.23*109就是1.23e9,或者12.3e8,0.000012可以写成1.2e-5,等等。
整数和浮点数在计算机内部存储的方式是不同的,整数运算永远是精确的而浮点数运算则可能会有四舍五入的误差。
About decimal inaccuracy
Python defaults to 17 digits of precision, which is 16 digits after the decimal point. Although there are 16 digits, this accuracy is more and more inaccurate.
What should we do when our calculations need to use higher precision (more than 16 decimal places)?

plural

From the above figure we can see that the complex number complex is composed of real and imaginary numbers
To understand complex numbers, in fact, you need to understand imaginary numbers first. Imaginary numbers (that is, false and unreal numbers): A number whose square is a complex number is called an imaginary number.
A complex number is a number that can be written in the form a+bi, where a and b are real numbers and i is the imaginary unit (i.e. root of -1). In the complex number a+bi, a is called the real part of the complex number, b is called the imaginary part of the complex number (an imaginary number refers to a number whose square is negative), and i is called the imaginary number unit.
When the imaginary part is equal to zero, the complex number is a real number; when the imaginary part is not equal to zero, the complex number is called an imaginary number.
Note that the letter j in the imaginary part can be both uppercase and lowercase.






Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325208237&siteId=291194637