Py thon 选择题练习50 道(含答案) 50 道选择题: 1. 下面哪条语句可以打印出 "Hello, World!"? A. print("Hello, World!") B. echo("Hello, World!") C. printf("Hello, World!") D. sy stem.ou t("Hello, World!") 答案:A。print() 用于输出结果,而且 Py thon 是大小写敏感的。 2. 在 Py thon 中,下划线(_)代表什么? A. 乘法操作符 B. 变量名 C. 匿名函数 D. 上一个表达式的结果 答案:D。在 Py thon 解释器中,_ 表示上一个表达式的结果。 3. 在 Py thon 中,如何声明字符串变量 strVar 并将其初始化为 "Hello, World!"? A. strVar = "Hello, World!" B. string strVar = "Hello, World!" C. str strVar = "Hello, World!" D. var strVar = "Hello, World!" 答案:A。在 Python 中,使用变量名 = 值 的语法来声明和初始化变量。 4. 在 Python 中,以下哪条语句可以将两个列表 list1 和 list2 中的元素合并到一个新的列表 newList 中? A. newList = list1 + list2 B. newList = list1.append(list2) C. newList = list1.extend(list2) D. newList = list1.join(list2) 答案:A。在 Python 中,使用加号运算符 (+) 将两个列表合并在一起,而 append() 和 extend() 方法用于向列表中添加元素。 5. 在 Python 中,以下哪条语句可以删除列表 myList 中的第一个元素? A. del my List[0] B. my List.pop(0) C. my List.remov e(0) D. my List.delete(0) 答案:B。pop() 方法用于删除列表中指定位置的元素,并返回被删除的元素的值。 6. 在 Py thon 中,以下哪个操作符用于计算两个数的余数? A. % B. ** C. / D. // 答案:A。% 运算符用于计算两个数之间的余数。 7. 在 Py thon 中,以下哪条语句可以将字符串 str1 转换为一个整数类型的变量? A. int(str1) B. float(str1) C. str1.int() D. str1.to_int() 答案:A。int() 函数用于将字符串转换为整数类型。 8. 在 Python 中,以下哪个标识符表示 "假"? A. true B. yes C. false D. no 答案:C。在 Python 中,True 表示真,False 表示假。 9. 在 Python 中,以下哪个函数可以返回一个列表中元素的个数? A. list.count() B. list.size() C. list.items() D. list.len(...