Python复习题库带答案

1.下列Python语句的输出结果是(  NoneType> )

def f():pass    

print(type(f()))

  1. Python语句a,b=3,4;a,b=b,a;print(a,b)的结果是 4 , 3
  2. Python通过内置函数(type())来测试对象的类型,通过(==)运算符判断两个变量指向的对象的值是否相同
  3. Python提供两个对象身份比较运算符,(is)和(is not)来判断两个变量是否指向同一个对象
  4. Python表达式4.5/2的值为(2.25);Python表达式4.5//2的值为(2);Python表达式4.5%2的值为(0.5);Python表达式12/4-2+5*8/4%5/2的值为(1.0)
  5. 计算232-1的python表达式可书写成(math.pow(2,32)-1)
  6. Python中如果语句太长,可以使用(\)作为续航符
  7. Python使用(缩进对齐)格式划分语句块
  8. Python语句分为(简单语句)和复合语句
  9. Python语句print(hex(16))的输出结果是0x10
  10. Python表达式 16-2*5>7*8/2 or "XYZ"!="xyz" and not(10-6>18/2)的值为(True)
  11. Python语句print(2.5.as_integer_ratio())的输出结果是((5,2))
  12. Python语句print(float.as_integer_ratio(1.5))的输出结果是((3,2)
  13. Python语句print(int('20',16),int('101',2))的输出结果是32 5
  14. Python语句print((2-3j).conjugate()*complex(2,3))的输出结果是-5+12J
  15. Python语句print(chr(ord('B')))的结果是(B)
  16. Python表达式 0 and 1 or not 2-----False
  17. Python语句print(divmod(7,4))的输出结果是((1,3))
  18. Python语句print(floor(15.5))的输出结果是15
  19. Python语句print(round(18.67,-1))的输出结果是20
  20. 已知a=3;b=5;c=6;d=True,则表达式 not d or a>=0 and a+c>b+3 的值是True
  21. Python语句 x=0;y=True;print(x>=y and 'A'<'B')的程序运行结果是(False)
  22. Python语句print(bin(10))的输出结果是(0b1010)
  23. Python表达式 3**2**3的值为(6561)
  24. Python的标准随机数生成模块是(random)
  25. Python语句print(gcd(12,16))的输出结果是(4)
  26. Python语句 x=True;y=False;print(x or y and z)的程序运行结果是True

1.Python语句pint('\x48\x41!')的运行结果是_

A、x48\x41!'

B、4841!

C、4841

D、HA!

正确答案:D

2.Python 语句print(type((1, 2, 3, 4))的输出结果是_

A、

B、

C、

D、

正确答案:A

3.Python 语句s={'a',1,'b',2};print(s['b'])的运行结果是

A、语法错

B、b'

C、1

D、2

正确答案:A

4.Python 语句nums = set([1,2,2,3,3,3,4]);print(len(nums))的输出结果是_

A、1

B、2

   C、4

   D、7

 

正确答案:C

5.Python 语句s='hello';print(s[1:3])的运行结果是_

A、hel

B、he

   C、ell

    D、el

 

正确答案:D

6.Python语句a=(1,2,3,Nne,(),[],); print(len(a))运行结果是

A、语法错

B、4

C、5

D、6

正确答案:D


Pyhon语句pinint(r"\nGood")的运行结果是

A、新行和字符串Good

B、r"nGood"

C、\nGood

D、字符T、新行和字符串Good

正确答案:C

8.Python语句d={1:'a',2:'b',3:'c'}; print(len(d))的运行结果是

A、0

B、1

C、3

D、6

正确答案:C

Python 语句print(type({1, 2, 3, 4}))的输出结果是

  • A、
  • B、
  • C、
  • D、

正确答案:C

10.Python 语句a= [1,2,3,None,0,[],];print(len(a))的输出结果是

A、4

B、5

C、6

D、7

 

正确答案:C

 

 

 

你可能感兴趣的:(Python复习题库带答案)