Python core data type Numeric type and set

Source: Internet
Author: User
Related computing operation description x + y addition x ** y multiplication side x-y subtraction x % y modulo (xmody) x * y multiplication + x mona1 addition xy division (2.6 removes decimals)-y unary subtraction xy truncation division xifyelsez ternary expression comparison operation... related computing
Operation Description Operation Description
X + y Addition X ** y Multiplication party
X-y Subtraction X % y Modulo (x mod y)
X * y Multiplication + X Mona1 addition
X/y Division (2.6 saving the fractional part) -Y Unary subtraction
X // y Truncation X if y else z Ternary expression
Comparison
Operation Description Operation Description
X <y X shifts y places to the left. X \ Y By bit or
X> y X shifts right to y places X ^ y Bitwise OR
X & y Bitwise AND ~ X Reverse search by bit
Description of numbers

Is_integer
Test whether the floating point number is an integer.

Numeric-related modulesmath,random
Int () and math. trunc () will omit the decimal part. the round () function can be rounding, math. the floor will retain the decimal place as 0 in 2.7, and the effect is the same as that in int in 3.0.

Python3.0 does not support Dictionary comparison and can be replaced by sorted (dict. items ().

Set

Add () insert
Update () returns the Union by position
Remove () deletes a project by value

Why use a set?

Filter out repeated items
Record the Accessed locations

The above is the details of the python core data type Numeric type and set. For more information, see other related articles in the first PHP community!

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.