零基础学python第六课 Pyhon之常用操作符

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wuxiaowu547/article/details/88541348

一、除法\和\的区别
在这里插入图片描述
二、python里的and和or
3 and 4 == 4,而 3 or 4 == 3。
not 1 or 0 and 1 or 3 and 4 or 5 and 6 or 7 and 8 and 9
not or and 的优先级是不同的:not > and > or

我们按照优先级给它们加上括号:(not 1) or (0 and 1) or (3 and 4) or (5 and 6) or (7 and 8 and 9)
== 0 or 0 or 4 or 6 or 9
== 4
三、print(2 ** 2 ** 32)和 print( (2 ** 2) ** 32)区别
print(2 ** 2 ** 32)
一般很多机子都会在一会儿之后:Memory Overflow,内存不够用。
设计到幂操作,结果都是惊人滴。
print( (2 ** 2) ** 32) 就可以计算出结果。

猜你喜欢

转载自blog.csdn.net/wuxiaowu547/article/details/88541348
今日推荐