Summary of basic types of Python Operators

Source: Internet
Author: User

Operator application in Python programming language is a basic application technology. For beginners, they need to master this application technique to facilitate future application. Here we will take a look at the basic concepts of the Python operator.

Python operator 1) Mixed Mode Operator

Python supports adding different numeric types.

 
 
  1. >>> 20+3.5698  
  2. 23.569800000000001 

Python operator 2) standard type operation

 
 
  1. >>> a=1.2  
  2. >>> b=1.20  
  3. >>> a==b  
  4. True  
  5. >>> a>b  
  6. False  
  7. >>> b<b 
  8. False  
  9. >>> a>=b  
  10. True  
  11. >>> a<=b  
  12. True  
  13. >>> (a==b) or(a>=b)  
  14. True 

Python Operator 3) Arithmetic Operator

 
 
  1. +,-,*,/,%,**,//  
  2. >>> 7.3/7  
  3. 1.0428571428571429  
  4. >>> 7.3//7  
  5. 1.0  
  6. >>> 4**3  
  7. 64  
  8. >>> 

Python Operator 4) bitwise Operator

Bitwise operations only support integers.

Reverse (~), Shifts by bit and (&), or (|), or (^), left (<), and right (> ).

 
 
  1. >>> 4**3  
  2. 64  
  3. >>> 20&35  
  4. 0  
  5. >>> 30&45  
  6. 12  
  7. >>> 30|45  
  8. 63  
  9. >>> 30<<2 
  10. 120  
  11. >>> 30<<2 
  12. 120  
  13. >>> ~30  
  14. -31  
  15. >>> 30 ^ 45  
  16. 51  
  17. >>> 

The above is the concept of the Python operator we will introduce in detail.

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.