发布时间 : 星期日 文章2020年《python程序设计》基础知识及程序设计598题OD[含参考答案]更新完毕开始阅读29a3cff2842458fb770bf78a6529647d26283462
2020年《python程序设计》基础知识及程序设计
598题[含参考答案]
一、填空题
1.表达式 len('abcdefg'.ljust(3)) 的值为_________。(7)
2.表达式 'abcdefg'.split('d') 的值为__________________。(['abc', 'efg'])
3.假设正则表达式模块re已导入,那么表达式 re.sub('\\d+', '1', 'a12345bbbb67c890d0e') 的值为_____________________。('a1bbbb1c1d1e')
4.在设计正则表达式时,字符_______紧随任何其他限定符(*.+.?.{n}.{n,}.{n,m})之后时,匹配模式是“非贪心的”,匹配搜索到的.尽可能短的字符串。(?)
5.代码 print(re.match('^[a-zA-Z]+$','abcDEFG000')) 的输出结果为_________。(None)
6.表达式 'test.py'.endswith(('.py', '.pyw')) 的值为__________。(True)
7.表达式 'Hello world!'[-4:] 的值为________________。('rld!')
8.假设re模块已导入,那么表达式 re.findall('(\\d)\\\\1+', '33abcd112') 的值为___________________。(['3', '1'])
9.已知字符串 x = 'hello world',那么执行语句 x.replace('hello', 'hi') 之后,x的值为____________。('hello world')
10.表达式 'a' + 'b' 的值为_____________。('ab')
11.已知 x = 'a b c d',那么表达式 ','.join(x.split()) 的值为___________。('a,b,c,d')
12.表达式 'C:\\\\Windows\\\\notepad.exe'.startswith('C:') 的值为_________。(True)
13.表达式 r'c:\\windows\\notepad.exe'.endswith(('.jpg', '.exe')) 的值为_______。(True)
14.表达式 r'c:\\windows\\notepad.exe'.endswith('.exe') 的值为_____________。(True)
15.表达式 'Hello world'.lower().upper() 的值为___________。('HELLO WORLD')
16.表达式 'Hello world'.lower() 的值为_____________。('hello world')
17.表达式 'Hello world'.upper() 的值为___________。('HELLO WORLD')
18.已知x = 'hello world',那么表达式x.replace('l', 'g')的值为_______________。('heggo worgd')
19.表达式 ''.join(re.split('[sd]','asdssfff')) 的值为_______________。('afff')
20.表达式 'C:\\\\windows\\\\notepad.exe'.endswith('.exe') 的值为________。(True)
21.已知函数定义def demo(x, y, op):return eval(str(x)+op+str(y)),那么表达式demo(3, 5, '+')的值为______________________。(8)
22.已知字符串编码格式gbk使用2个字节表示一个汉字.1个字节表示英语字母,那么表达式len('abc你好'.encode('gbk'))的值为_______________。(7)
23.已知字符串编码格式utf8使用3个字节表示一个汉字.1个字节表示英语字母,那么表达式len('abc你好'.encode())的值为_______________。(9)
24.字符串编码格式GBK使用__________________个字节表示一个汉字。(2)
25.字符串编码格式UTF8使用____________________个字节表示一个汉字。(3)
26.已知 x = 'abcdefg',则表达式 x[3:] + x[:3] 的值为___________________。('defgabc')
27.表达式 len('SDIBT') 的值为__________。(5)
28.表达式 len('中国'.encode('gbk')) 的值为____________。(4)
29.表达式 'aaasdf'.strip('af') 的值为______________。('sd')
30.表达式 'apple.peach,banana,pear'.find('ppp') 的值为________。(-1)
31.表达式 'abc10'.isalnum() 的值为______________。(True)
32.表达式 eval('''__import__('math').sqrt(3**2+4**2)''') 的值为_________。(5.0)
33.表达式 eval('''__import__('math').sqrt(9)''') 的值为______________。(3.0)
34.代码 print(1,2,3,sep=':') 的执行结果为__________________。(1:2:3)
35.表达式 'abc.txt'.endswith(('.txt', '.doc', '.jpg')) 的值为___________。(True)
36.表达式 [str(i) for i in range(3)] 的值为____________。(['0', '1', '2'])
37.正则表达式元字符________用来表示该符号前面的字符或子模式0次或多次出现。(*)
38.表达式 'aaasdf'.rstrip('af') 的值为_______________。('aaasd')
39.Python中用于表示逻辑与.逻辑或.逻辑非运算的关键字分别是_________.___________._________。(and.or.not)
40.表达式 ','.join('a b ccc\\n\\n\\nddd '.split()) 的值为______________。('a,b,ccc,ddd')
41.表达式 'ac' in 'abce' 的值为_____________。(False)
42.表达式 3 in {1, 2, 3} 的值为_________。(True)
43.Python关键字elif表示__________和___________两个单词的缩写。(else.if)
44.表达式 5 if 5>6 else (6 if 3>2 else 5) 的值为_________。(6)
45.在循环语句中,_______语句的作用是提前进入下一次循环。(continue)
46.在循环语句中,__________语句的作用是提前结束本层循环。(break)
47.表达式 'abc' in ['abcdefg'] 的值为______________。(False)
48.Python 3.x语句 print(1, 2, 3, sep=',') 的输出结果为________________。(1,2,3)
49.Python语句''.join(list('hello world!'))执行的结果是____________________。('hello world!')
50.表达式 3 and 5 的值为____________。(5)
51.表达式 3 or 5 的值为________。(3)
52.表达式 1<2<3 的值为_________。(True)
53.已知 x = {'a':'b', 'c':'d'},那么表达式 'b' in x.values() 的值为______________。(True)
54.已知 x = {'a':'b', 'c':'d'},那么表达式 'b' in x 的值为______________。(False)
55.已知 x = {'a':'b', 'c':'d'},那么表达式 'a' in x 的值为______________。(True)
56.表达式 3<5>2 的值为_______________。(True)
57.对于带有else子句的for循环和while循环,当循环因循环条件不成立而自然结束时________(会?不会?)执行else中的代码。(会)
58.表达式 sum(range(1, 10, 2)) 的值为____________。(25)
59.表达式 'abcabcabc'.count('abc') 的值为_____________。(3)
60.表达式 'Hello world. I like Python.'.rfind('python') 的值为________。(-1)
61.表达式 ':'.join('abcdefg'.split('cd')) 的值为______________。('ab:efg')
62.表达式 isinstance(3, object) 的值为_____________。(True)
63.表达式 isinstance('abcdefg', str) 的值为____________。(True)
64.表达式 'The first:{1}, the second is {0}'.format(65,97) 的值为______________________________。('The first:97, the second is 65')
65.表达式 '%d,%c' % (65, 65) 的值为________。('65,A')
66.表达式 not 3 的值为________________。(False)
67.表达式 '%c'e 的值为_________。('A')
68.假设已成功导入Python标准库string,那么表达式len(string.digits)的值为_______________。(10)