Python Learning Diary---programming Tips 1

Source: Internet
Author: User

    1. In python3.x, the print () function performs a wrap-around effect, and the following example resolves that it does not wrap

Print (xxx,end= "")//Make parameter end value empty

2. Two kinds of equality in Python:

FLOAT1 = 2.5

FLOAT2 = 2.5

FLOAT3 = Float2

Where FLOAT1 is equal to FLOAT2 value and does not point to the same object

FLOAT3 is equal to FLOAT2 value, pointing to the same object

3. floating-point variable in the application, compared with the ' = = ' is not suitable

delta=0.0 000 001

if (Math.fabs (x-y) < Delta)//Gap considered equal

4. Multiple Assignments

There is another way of assigning values in Python

AInt, bInt, cInt = 15, 10, 17

Equivalent to

AInt = 15

BInt = 10

CInt = 17

Example of variable exchange:

A, B = B, a

Equivalent to

Temp = A

A = B

B = Temp

Can also be exchanged in this way

A, B, C = c,a,b// 6 Fly!

Python Learning Diary---programming Tips 1

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: 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.