Getting started with the zero-learning Python (quad) operation

Source: Internet
Author: User
Python operators are similar to other languages

(We only know the basic usage of these operators for the time being, so we could expand the content later, the advanced application is not introduced at the moment)

Mathematical operations

The code is as follows:


>>>print 1+9 # Addition

>>>print 1.3-4 # Subtraction

>>>print 3*5 # multiplication

>>>print 4.5/1.5 # Division

>>>print 3**2 # exponentiation

>>>print 10%3 # seeking remainder

Judge

Judging whether it's true or false, return to True/false

The code is as follows:


>>>print 5==6 # =, equal

>>>print 8.0!=8.0 #! =, Unequal

>>>print 3<3, 3<=3 # <, less than; <=, less than or equal to

>>>print 4>5, 4>=0 #, greater than; >=, greater than or equal to

>>>print 5 in [1,3,5] # 5 is an element of list [1,3,5]

And is, are not, etc., temporarily not in depth)


Logical operations

Operations between the True/false

The code is as follows:


>>>print true and True, True and False # and, "and" operations, both are true

>>>print true or False # or, "or" operation, one of which is true is true

>>>print not True # not, "non" operation, negation

You can do some exercises with the previous section, such as:

The code is as follows:


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

Summarize

Math +,-, *,/, * *,%

Judge = =,! =,, >=, <, <=, in

Logical AND, or, not

  • 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.