码迷,mamicode.com
首页 > 编程语言 > 详细

Python开发【第二章】:Python的运算符

时间:2016-08-01 11:58:18      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:

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 << 2;       # 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
View Code

8、运算符优先级:

技术分享

 

点击查看更多内容:Python运算符

Python开发【第二章】:Python的运算符

标签:

原文地址:http://www.cnblogs.com/lianzhilei/p/5724847.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!