首页 > 编程语言 > 详细

python的基本操作运算符

时间:2020-07-03 13:01:06      阅读:56      评论:0      收藏:0      [点我收藏+]
#幂次运算 **
mici = 1
while mici <= 9:
    print(2**mici,end=" ") #打印2的n次幂
    mici += 1
#取整运算 //
print("\n取整运算:5//3 = ",5//3)

‘‘‘
逻辑运算:
或:or
与:and
非:not
优先级问题:
有括号先算括号里边的,算完括号里边的,先算not ,再算and,最后算or
如果出现x or y,当x是0的时候输出结果就是y,否则就是x
如果出现x and y,当x是0的时候,输出的是0,如果不是0,输出的就是y
‘‘‘
print(3 or 2)
print(0 or 2 or 3 or 4)
print(1 and 2 and 3)
print(0 and 3 and 2)

 

python的基本操作运算符

原文:https://www.cnblogs.com/boost/p/13229385.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!