Python Day2 Basics 2

Source: Internet
Author: User

Data type First Knowledge 1, number

2 is an example of an integer.
Long integers are just larger integers.
3.23 and 52.3E-4 are examples of floating-point numbers. The e tag represents a power of 10. Here, 52.3E-4 means 52.3 * 10-4.
( -5+4j) and (2.3-4.6j) are examples of complex numbers, where -5,4 is a real number, j is an imaginary number, and what is the plural in mathematics?

int (integral type)

On a 32-bit machine, the number of integers is 32 bits and the value range is -2**31~2**31-1, which is -2147483648~2147483647
On a 64-bit system, the number of integers is 64 bits and the value range is -2**63~2**63-1, which is -9223372036854775808~9223372036854775807long (Long integer)
Unlike the C language, Python's long integers do not refer to the positioning width, that is, Python does not limit the size of long integer values, but in fact, because of limited machine memory, we use a long integer value can not be infinite.
Note that, since Python2.2, Python automatically converts integer data to long integers if an integer overflows, so it does not cause any serious consequences if you do not add the letter L after long integer data.
Float (float) floats are used to process real numbers, that is, numbers with decimals. Similar to the double type in C, accounting for 8 bytes (64 bits), where 52 bits represent the bottom, 11 bits represent the exponent, and the remaining one represents the symbol.
Complex (plural)
The complex number consists of real and imaginary parts, the general form is X+yj, where x is the real part of the complex, and Y is the imaginary part of the complex, where x and y are real numbers. Note: Small number pools exist in Python:-5 ~ 257 2, Boolean true or False 1 or 0 3, string
Helo World
Data OperationsArithmetic operations:

>>> 8 40>>> 8 53>>> 8 62>>> 8 71>>> 10/33.3333333333333335 >>>>>>//33>>>

Comparison operation:

Assignment operation:

Logical operation:

>>> a,b,c = 2,5,8>>>>>> a >1 andB > 7False>>> a >1 andB > 4True>>>>>> a >1 andB > 4 andC >7True>>>>>> a >1 andB > 4 andC >7orc = = 10True>>>>>>>>> a >1 andB > 4 andC >9orc = = 10False>>>>>> a >1 andB > 4 andC >6orc = = 10True

Member Operations:

>>> a = [1,2,3,4]ifnot inprint('sadasasdasdas  ') ... if  not inch Print ('sadasasdasdas') ... sadasasdasdas>>>

Identity operation:

Bit operations:

Operator Precedence:

List

Definition List

>>> names =["Xiao Ming","Xiao Hong","  Li gang","li Ming"]

Computers starting from 0 count

>>> names =["Xiao Ming","Xiao Hong","Li Gang","Li Ming"]>>>Names[0]'Xiao Ming'>>> names[1]'Xiao Hong'>>> names[2]'Li Gang'>>> names[3]'Li Ming'>>>>>> Names[-1]#take the last one .'Li Ming'>>> Names[-2]#take the second from the bottom.'Li Gang'>>>

Python Day2 Basics 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.