Author: vamei Source: http://www.cnblogs.com/vamei welcome reprint, please also keep this statement. Thank you!
Python operators are similar to those in other languages.
(Currently, we only know the basic usage of these operators, so that we can expand the following content. Advanced applications are not introduced at the moment)
1. mathematical operations
>>> Print 1 + 9# Addition
>>> Print 1.3-4# Subtraction
>>> Print 3*5# Multiplication
>>> Print 4.5/1.5# Division
>>> Print 3 ** 2# Multiplication
>>> Print 10% 3# Finding the remainder
2. Judgment
Returns true/false if it is true or false.
>>> Print 5 = 6# =, Equal
>>> Print 8.0! = 8.0#! =, Not equal
>>> Print 3 <3, 3 <= 3# <, Less than; <=, less than or equal
>>> Print 4> 5, 4> = 0#>, Greater than; >=, greater than or equal
>>> Print 5 in [1, 3, 5]#5 is an element of list [1, 3, 5 ].
(There are also is, is not, and so on, not in-depth)
3. logical operations
Operation between true and false
>>> Print true and true, true and false# And, "and" operations, both of which are true
>>> Print true or false# Or, "or" operation. If one of them is true, it is true.
>>> Print not true# Not, non operation, Inverse Operation
It can be used with the previous part to do some exercises, such:
>>> Print 5 = 6 or 3> = 3
Summary:
Mathematics+,-, *,/, **, %
Judgment= ,! =,>,> =, <, <=, In
LogicAnd, or, not