Basic Python data types — numbers 1. Integers Integers have no decimal points.

For example, 0, -1, 23333333

I don’t know the integer length limit in Python, but you can write superbits

Unlike a lot of other programming languages that have int SmallINT longint

Don’t believe it?

Let’s try

640.png

6**666 means 6 to the power of 666. Well, that’s a lot of data for you

Python has a wide variety of integer headers, including decimal, binary, hexadecimal, and octal

Now do not understand the system does not matter, want to know if you can baidu, I will not be long

Their mutual transformation can refer to: http://www.cnblogs.com/xugang/archive/2008/08/02/1258610.html

Decimal notation is normal notation

In binary notation, prefix is 0B, and only the combination of 0 and 1 digits can be displayed, for example, 0b1001110

Octal notation, prefixed with 0o, produces a combination of 0 to 7 digits, such as 0o76543210

In hexadecimal notation, prefix 0x is used to display digits and letters ranging from 0 to 9 and A to F, for example, 0xA20974BCF

At runtime, they will automatically convert to decimal output, so let’s try

640 (1).png

2. Floating-point numbers Simple points are numbers with a decimal point

Underline: Floating point numbers can only be written in decimal notation, that is, without a prefix

Don’t believe it? Have a try

640 (2).png

A red, green and yellow error popped up after running

Let’s Google translate it. It means grammatical error

Indicates that you cannot add a decimal point to binary notation

Of course, in addition to this mistake, you can make another one (if you listen carefully)

640.jpg

What? Listen well and you’re more likely to make mistakes! I’m out of this class!

Python failed to get started…

The error is that an int can be 6**666

So let’s add a decimal point to six to make it a floating point number, nothing else. Let’s run it

640 (3).png

Display overflow error: Results too large to bear!

Pay attention to this mistake!

Floating point numbers also include fractions

640 (4).png

Because it is infinite loop, so display and save is error

3. The Boolean value

Boolean values are what we call logic

You can think of it as right or wrong, heads or tails

For example, in a Chinese action love movie:

640 (1).jpg

She began to tear rose petals after being lovelorn

(Two red keywords for love and action)

Do you love me or not

640 (2).jpg

love

Do not love

love

Do not love

love

After several times…

love

Do not love

love

Do not love

Woman: Let me go to hell

640 (3).jpg

You can think of only two cases: love or not love, which corresponds to the logic True or False

Let’s look at an example:

640 (5).png

233 (int) = 233.0 (float)

This refreshes my three views, isn’t it agreed that their data types are different?

640 (4).jpg

Note that the two values are only being compared to see if they are equal. 233 and 233.0 can be considered equal, but the accuracy reservation is different

So why isn’t 233 the same as 233?

Because ‘233’ is a string, it cannot be numerically computed, and 233 is a number

4. The plural

What is a complex number? In junior high school, we thought that the rational number can represent everything, suddenly kill an unreasonable unreasonable number

The rational and irrational numbers are called real numbers

In addition to the real numbers, there is a complex number

Interested in self-ferrying

In Paisson, the complex number is expressed like this:

640 (6).png

Type returns complex, which means complex, and complex is complicated, with a j in it, and if the girls are real, the boys are?? 【 bad smile

But you can’t write:

640 (7).png

Anyone who has studied complex numbers knows the real and imaginary parts of complex numbers

640 (8).png

This can be obtained by enclosing them and using the real (real) and IMAG (fake) methods

That concludes the data type classification of numbers

Today’s assignment: Follow my instructions once (dare to say it differently)

Class is over

Life is short. I’m going to go with Python

To be continued, serial……