#680. Q_006
Q_006
选择题
- 下列哪项是 Python 的合法注释方式?( ) {{ select(1) }}
// This is a comment<!-- This is a comment --># This is a comment/* This is a comment */
- 执行
print(7 % 3)的结果是?( ) {{ select(2) }}
- 1
- 2
- 3
- 0
- 列表
a = [10, 20, 30],执行a.pop()后,a的值是?( ) {{ select(3) }}
[10, 20][20, 30][10, 30][10, 20, 30]
- 表达式
len([1, [2, 3], 4])的结果是?( ) {{ select(4) }}
- 3
- 4
- 5
- 报错
- 关于字符串方法
.upper(),以下说法正确的是?( ) {{ select(5) }}
- 将字符串转为小写
- 修改原字符串为大写
- 返回一个新字符串,内容为大写
- 只能用于英文字符
- 字典
d = {'x': 1, 'y': 2},执行d['z'] = 3后,len(d)的值是?( ) {{ select(6) }}
- 2
- 3
- 4
- 报错
- 执行以下代码后,输出是?
for i in range(2, 6, 2):
print(i, end=' ')
{{ select(7) }}
2 42 3 4 52 4 60 2 4
- 下列哪个数据类型不能作为字典的键?( ) {{ select(8) }}
- 整数
- 字符串
- 元组
- 列表
- 要将字符串
"123"转换为整数,应使用?( ) {{ select(9) }}
int("123")str.to_int("123")convert("123", int)parse_int("123")
- 执行
bool([])的结果是?( ) {{ select(10) }}
TrueFalse[]- 报错
- 关于
if-elif-else结构,以下说法正确的是?( ) {{ select(11) }}
- 必须包含
elif else分支可以单独存在- 多个
elif中只要有一个条件为真,其余不再判断 - 所有分支都会被执行
- 在 Turtle 中,要隐藏画笔形状,应使用?( ) {{ select(12) }}
turtle.hide()turtle.invisible()turtle.hideturtle()turtle.shape(None)
- 集合
a = {1, 2, 3},集合b = {3, 4, 5},a | b的结果是?( ) {{ select(13) }}
{3}{1, 2, 3, 4, 5}{1, 2, 4, 5}{1, 2, 3, 3, 4, 5}
- 下列哪行代码能正确创建一个元组?( ) {{ select(14) }}
t = (1)t = [1,]t = (1,)t = {1}
- 执行
round(3.14159, 2)的结果是?( ) {{ select(15) }}
- 3.14
- 3.142
- 3.1
- 3
- 关于函数参数,以下说法正确的是?( ) {{ select(16) }}
- 实参必须与形参同名
- 函数调用时参数顺序可以任意
- 默认参数必须放在非默认参数之后
- 函数不能没有参数
- 要清空列表
lst中的所有元素,最直接的方法是?( ) {{ select(17) }}
lst = []lst.clear()del lst[:]- 以上都可以
- 执行以下代码后,
result的值是?
result = "a" in "apple"
{{ select(18) }}
'a'TrueFalse- 报错
- 下列哪个不是 Python 的内置函数?( ) {{ select(19) }}
len()max()sort()sum()
- 程序出现 “NameError: name 'x' is not defined”,最可能的原因是?( ) {{ select(20) }}
- 变量
x未赋值就使用 x是关键字- 文件编码错误
- 缩进错误
- 关于文件操作,
open("file.txt", "r")表示?( ) {{ select(21) }}
- 以写入模式打开文件
- 以追加模式打开文件
- 以只读模式打开文件
- 创建新文件
- 执行
list(range(1, 4))的结果是?( ) {{ select(22) }}
[1, 2, 3][0, 1, 2, 3][1, 2, 3, 4][0, 1, 2]
- 下列哪项能正确交换变量
a和b的值?( ) {{ select(23) }}
a = b; b = atemp = a; a = b; b = tempa, b = b, a- B 和 C 都对
- 要生成 1 到 100 的随机整数,应使用?( ) {{ select(24) }}
random.randint(1, 100)random.random(1, 100)random.choice(1, 100)random.range(1, 100)
- 执行
print(type([1, 2]))的结果包含?( ) {{ select(25) }}
<class 'tuple'><class 'list'><class 'dict'><class 'set'>
判断题
- Python 中,缩进用于表示代码块。( ) {{ select(26) }}
- 对
- 错
- 字符串
"hello"和"Hello"是相等的。( ) {{ select(27) }}
- 对
- 错
- 列表
[1, 2] + [3]的结果是[1, 2, 3]。( ) {{ select(28) }}
- 对
- 错
- 字典的键必须是不可变类型。( ) {{ select(29) }}
- 对
- 错
0 == False在 Python 中返回True。( ) {{ select(30) }}
- 对
- 错
for循环不能遍历字符串。( ) {{ select(31) }}
- 对
- 错
- 空字典
{}的布尔值为False。( ) {{ select(32) }}
- 对
- 错
import math后,可直接使用sqrt(4)。( ) {{ select(33) }}
- 对
- 错
range(5)和range(0, 5)是等价的。( ) {{ select(34) }}
- 对
- 错
- 在 Python 中,
=是比较运算符。( ) {{ select(35) }}
- 对
- 错
相关
在下列比赛中: