2020
年《
python
程序设计》基础知识及程序设计
598
题
[
含参考答案
]
一、填空题
1
.
表达式
len('abc'.ljust(20))
的值为
______________
。(
20
)
2
.
Python
3.x
语句
for
i
in
range(3):print(i,
end=',')
的输出结果为
_____________________
。
(
0,1,2,
)
3
.
已知字符串
x
=
'hello
world'
,那么执行语句
x.replace('hello',
'hi')
之后,
x
的值为
____________
。(
'hello world'
)
4
.
表
达
式
'hello
world,
hellow
every
one'.replace('hello',
'hi')
的
值
为
________________________
。(
'hi world, hiw every one'
)
5
.
已知
table = ''.maketrans('abcw', 'xyzc')
,那么表达式
'Hellow world'.translate(table)
的值为
______________________
。(
'Helloc corld'
)
6
.
表达式
'abcab'.replace('a','yy')
的值为
___________
。(
'yybcyyb'
)
7
.
表达式
chr(ord('A')+2)
的值为
__________
。(
'C'
)
8
.
表达式
'abcab'.strip('ab')
的值为
__________
。(
'c'
)
9
.
代码
print(re.match('^[a-zA-Z]+$','abcDEFG000'))
的输出结果为
_________
。(
None
)
10
.
表达式
'abc.txt'.endswith(('.txt', '.doc', '.jpg'))
的值为
___________
。(
True
)
11
.
表达式
'test.py'.endswith(('.py', '.pyw'))
的值为
__________
。(
True
)
12
.
表达式
'Hello world!'[-4:]
的值为
________________
。(
'rld!'
)
13
.
表达式
'Hello world!'[-4]
的值为
________________
。(
'r'
)
14
.
语句
print(re.match('abc', 'defg'))
输出结果为
_____________
。(
None
)