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

python的基本操作运算符

时间:2020-07-03 12:09:28      阅读:57      评论:0      收藏:0      [点我收藏+]

标签:+=   end   问题:   bsp   mic   int   打印   while   and   

#幂次运算 **
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的基本操作运算符

标签:+=   end   问题:   bsp   mic   int   打印   while   and   

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

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