My Python growth path---first day---python Basics (4)---December 26, 2015 (haze)

Source: Internet
Author: User
Tags arithmetic operators bitwise bitwise operators

Data operations and data operators

Arithmetic operators

Arithmetic operators
Operator Describe Example
+ Addition

>>> 14-5
9

- Subtraction
>>> 14-59
* Multiplication
>>> 5 * 1470
/ Division
>>> 14/52.8
% Modulo, that is, two of the number of quotient of the remainder of the part
>>> 14% 54
** Power operation
>>> 2 * * 38
// The integer portion of a quotient that returns two numbers.
>>> 10//33

Comparison operators: Comparison operators are not limited to numbers, strings, lists, etc.

comparison Operators
Operator Describe Example
== Determines whether two objects are equal (equal returns TRUE, not equal returns false)
' ABC ' ' ABC ' True
!= Determines whether an object is not equal (as opposed to = =, returns false for equality, not equal returns True)
>>> 1! = 2True
<> Determine if an object is not equal (IBID., but not recommended)
> Determines whether the first object is greater than the second object, greater than return true, not greater than (including equals) returns Fasle
>>> 3 > 1True
< Determines whether the first object is less than the second object, is less than the return true, and is not less than (including equals) returned Fasle
>>> 3 < 4True
>= Returns True if the first object is greater than or equal to the second object, or False if it is greater than or equal to
>>> 3 >= 3True
<= Returns False if the first object is less than or equal to the second object, less than or equal to true.
>>> 3 <= 4True

Assignment operators: assigning operations

Assignment operators
Operator Describe Example
= Assign value A = C
+= Self-added assignment A + = 1 equivalent to a = a + 1 A + = 1
-= The self-decrement assignment A-= 1 is equivalent to a = A-1 A-= 1
*= Squared assignment A *= 1 is equivalent to a = a * 1 A *= 1
/= A/= 1 equivalent to a = A/1 A/= 1
%= Pickup mode assignment a%= 1 equivalent to a = a% 1 A%= 1
**= Self-seeking power assignment a **= 1 is equivalent to a = a * * 1 A**= 1
//= Self-divisible assignment a//= 1 is equivalent to a = A//1 A//= 1

Bitwise operators: logical calculations by bits

Bitwise operators
Operator Describe Example
& Bitwise-AND
>>> 5 & 144
| Bitwise OR
>>> 5 | 1415
^ XOR or
>>> 5 ^ 1411
<< Move left
>>> << 256
>> Move right
>>> >> 23

My Python growth path---first day---python Basics (4)---December 26, 2015 (haze)

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.