Python basic 4 commonly used operators

Source: Internet
Author: User

num + = 1 is equivalent to num = num + 1
Num-= 2 is equivalent to num = num-2
Num *= 3 equivalent to num = num * 3
Num/= 5 is equivalent to num = NUM/5
Num//= 7 equivalent to num = num//7
Num%= 8 equivalent to num = num% 8
Num **= 9 equivalent to num = num * * 9

or  and False Print (Luoji) # first, and then in the arithmetic Or,and the higher priority Result: True
logical Operators

List1 = [1,2,3,4,5,18,32,16]a= 10b= 32ifA not inchList1:Print("correct,%s is not in%s"%(a,list1))Else:    Print("wrong,%s is not in%s"%(a,list1))ifBinchList1:Print("correct,%s is in%s"%(b, List1))Else:    Print("wrong,%s is not in%s"%(b, List1)) results: Correct,10 is  not inch[1, 2, 3, 4, 5, 18, 32, 16]correct,32 is inch[1, 2, 3, 4, 5, 18, 32, 16]
member Operators

#identity operators are notA = 10b= 32ifA isB:Print("correct,%s is%s"%(A, b))ifA is  notB:Print("correct,%s is not%s"%(b)) a= 10b= 10ifA isB:Print("correct,%s is%s"%(A, b))ifA is  notB:Print("correct,%s is not%s"%(b)) results: Correct,10 is  not32correct,10 is10
identity operator

Python basic 4 commonly used operators

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.