Python (data types and variables)

Source: Internet
Author: User

1. Integers:

Hexadecimal prefix: 0x, with 0-9 and a-f to represent numbers. Example: 0xff00

2. Floating-point number: Because when represented by scientific notation, the decimal point position of a floating-point is variable, so it is called a floating-point number.

For a large number, the 10 is replaced by E, 1.24x10 9 times is 1.24e9,0.00012 written 1.2e-5

PS: integer arithmetic is always accurate (division is also accurate!) ), and the floating-point operation may have rounding errors.

3.

Escape character: \ (followed by the character to be escaped, to itself \ can also be escaped)

>>>Print('i\ ' m ok! "' )I'm ok!

Line break: \ n

tab: \ t

>>>Print('\\\n\\') \

Python also allows strings that are inside the "plus r" to be escaped by default:

Print ('\\\t\\') \        Print (R'\\\n\\') \\\n\>>>

If there is a lot of line wrapping inside the string, \n writing in one line is not good to read, in order to simplify, the "..." format for multiple lines of content:

Print ("'line1 ... line2 ... line3") Line1line2line3 # in fact, when you write the return line will automatically add ..., notice ... is a prompt is not part of the code

4. NULL: The null value is a special value in Python, expressed in None . Nonecannot be understood as 0 , because 0 it is meaningful, and None is a special null value.

5. Understand the representation of variables in computer memory when writing:

A='ABC'

The Python interpreter did two things:

    1. A string is created in memory ‘ABC‘ ;

    2. Creates a variable named in memory a and points it to the‘ABC‘

6. In Python, the return of the expression 0.1+0.2==0.3 is false (that is, 0.1+0.2!=0.3)

>>> 0.1+0.2==0.3False>>> 0.1+0.20.30000000000000004>>> 0.2+0.30.5

7. Note that the expression output is different

 is btrue  is Bfalse

   

Python (data types and variables)

Related Article

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.