python面试题集锦

一、python2X与python3X的区别

1、python2X源码杂乱,重复率高;python3X源码优美简洁明了。

2、python2X默认使用Unicode编码,仅支持英文数字特殊字符;python3X默认UTF-8编码,支持中文。

二、运算符

1、判断下列逻辑语句的True,False.

1)1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6

2)not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6

2、求出下列逻辑语句的值。

1),8 or 3 and 4 or 2 and 0 or 9 and 7

2),0 or 2 and 3 and 4 or 6 and 0 or 3

3、下列结果是什么?

1)、6 or 2 > 1

2)、3 or 2 > 1

3)、0 or 5 < 4

4)、5 < 4 or 3

5)、2 > 1 or 6

6)、3 and 2 > 1

7)、0 and 3 > 1

8)、2 > 1 and 3

9)、3 > 1 and 0

10)、3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2

判断依据:(1)运算优先级:not>and>or

     (2)对于or来说,若有一边为0,则结果为另一边;若无0,则为左边。对于and来说,若有一边为0,则为o;若无0,则为右边。

猜你喜欢

转载自www.cnblogs.com/hiDaLao/p/9418597.html