Python core data type numeric types and collections

Source: Internet
Author: User
Tags set set

Related calculations

Operation Description Operation Description
X + y Addition X * * y Powers
X-y Subtraction X% y modulo (x mod y)
X * y Multiplication +x One-dollar addition
X/Y Division (2.6 Omit the number of decimal parts) -Y One-dollar subtraction
X//Y Truncate except X if y else Z Three-dimensional expression

Compare operations

Operation Description Operation Description
X << y X left shift y bit X \ Y Bitwise OR
X >> y x right Shift y bit x ^ y Bitwise XOR OR
X & Y Bitwise-AND ~x Bitwise negation

Some notes about the numbers

Is_integer
Test whether a floating-point number is an integer official document

and value-dependent modules math ,random
Int () and Math.trunc () omit the fractional part, and the round () function can be rounded, with the math.floor holding the decimal place at 2.7 for 0, and the int effect at 3.0.

python3.0 no longer supports dictionary comparison sizes and can be replaced with sorted (Dict.items ())

Set Set

Add () Insert
Update () set by location
Remove () Deletes an item by value

Why use collections?

Filter out Duplicates
Record locations that have been visited

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.