My path to Python development-first day --- Python BASICS (4) --- December 26, 2015 (smog ),

Source: Internet
Author: User

My path to Python development-first day --- Python BASICS (4) --- December 26, 2015 (smog ),

V. Data Operations and Data Operators

Arithmetic Operators

Arithmetic Operators
Operator Description Example
+ Addition

>>> 14-5
9

- Subtraction
>>> 14 - 59
* Multiplication  
>>> 5 * 1470
/ Division  
>>> 14 / 52.8
% Modulo, that is, the remainder of two operators  
>>> 14 % 54
** Power Operation  
>>> 2 ** 38
// Returns the integer part of the quotient of two numbers.
>>> 10 // 33

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Comparison operators: Comparison operators are not limited to numbers, strings, lists, and so on.

Comparison Operators
Operator Description Example
= Determine whether two objects are equal (True is returned if they are equal, False is returned if they are not equal)
>>> 'abc' == 'abc'True
! = Checks whether the connected objects are not equal (opposite to =). If they are equal, False is returned. If they are not equal, True is returned)
>>> 1 != 2True
<> Determine whether the connected objects are not equal (same as above, but not recommended)  
> Judge whether the first object is greater than the second object. If the value is greater than True, no greater than (including equal), return Fasle.
>>> 3 > 1True
< Judge whether the first object is smaller than the second object. If the value is smaller than or equal to True, return Fasle.
>>> 3 < 4True
> = Determines whether the first object is greater than or equal to the second object. If the value is greater than or equal to the second object, True is returned. Otherwise, False is returned.
>>> 3 >= 3True
<= Determines whether the first object is less than or equal to the second object. If the value is less than or equal to the second object, True is returned. Otherwise, False is returned.
>>> 3 <= 4True

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Value assignment operator: Performs value assignment.

Value assignment operator
Operator Description Example
= Assignment A = c
+ = Auto-increment value a + = 1 is equivalent to a = a + 1 A + = 1
-= The auto-subtraction value a-= 1 is equivalent to a = a-1. A-= 1
* = The auto-multiplication value a * = 1 is equivalent to a = a * 1. A * = 1
/= The auto-division value a/= 1 is equivalent to a = a/1. A/= 1
% = The automodulo value a % = 1 is equivalent to a = a % 1. A % = 1
** = The self-calculated power value a ** = 1 is equivalent to a = a ** 1 A ** = 1
// = Auto-Division assignment a // = 1 is equivalent to a = a // 1 A // = 1

 

 

 

 

 

 

 

 

Bitwise OPERATOR: Performs logical computing based on binary

Bitwise operators
Operator Description Example
& Bitwise AND
>>> 5 & 144
| By bit or
>>> 5 | 1415
^ Exclusive or
>>> 5 ^ 1411
< Move left
>>> 14 << 256
> Right Shift
>>> 14 >> 23

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.