Introduction to indentation in basic python tutorials

  • 2020-04-02 13:59:38
  • OfStack

Python's operators are similar to those of other languages

(we have only the basic usage of these operators for the moment, so we can expand on the rest of the content. We will not cover advanced applications for the moment.)

Mathematical operations


>>>print 1+9        # add >>>print 1.3-4      # subtraction >>>print 3*5        # The multiplication >>>print 4.5/1.5    # division >>>print 3**2       # chengfang      >>>print 10%3       # Strives for the remainder

 

judge

To determine whether it is True or False, return True/False


>>>print 5==6               # = . equal >>>print 8.0!=8.0           # !=, Ranging from >>>print 3<3, 3<=3          # <, Less than ; <=, Less than or equal to >>>print 4>5, 4>=0          # >, Is greater than ; >=, Greater than or equal to >>>print 5 in [1,3,5]       # 5 is list [1,3,5] An element of

  (is, is not, etc.)

Logical operations

The operation between True and False


>>>print True and True, True and False      # and, And, It is true that both are true >>>print True or False                      # or, " or " Operation, One of them being true is true >>>print not True                           # not, "No" operations, The not

Some exercises can be combined with the previous part, such as:

>>>print 5==6 or 3>=3

 

conclusion

Mathematics +, -, *, /, **, %

= =,! =, > . > =, < . < =, in

Logic and, or, not


Related articles: