Python运算符

2021-05-18 12:31

阅读:715

标签:运算   逻辑   png   python运算   比较   print   line   技术   int   

1.算术运算:

技术分享图片

 

2.比较运算

技术分享图片

 

3.赋值运算:

技术分享图片

 

 4.逻辑运算

技术分享图片

 

5.成员运算:
技术分享图片

 

6.身份运算:

技术分享图片

 

7.位运算

技术分享图片

 

#!/usr/bin/python
 
a = 60            # 60 = 0011 1100
b = 13            # 13 = 0000 1101
c = 0
 
c = a & b;        # 12 = 0000 1100
print "Line 1 - Value of c is ", c
 
c = a | b;        # 61 = 0011 1101
print "Line 2 - Value of c is ", c
 
c = a ^ b;        # 49 = 0011 0001
print "Line 3 - Value of c is ", c
 
c = ~a;           # -61 = 1100 0011
print "Line 4 - Value of c is ", c
 
c = a # 240 = 1111 0000
print "Line 5 - Value of c is ", c
 
c = a >> 2;       # 15 = 0000 1111
print "Line 6 - Value of c is ", c

8.运算符优先级:

技术分享图片

 

Python运算符

标签:运算   逻辑   png   python运算   比较   print   line   技术   int   

原文地址:https://www.cnblogs.com/pythonlearing/p/9744601.html


评论


亲,登录后才可以留言!