1.What arithmetic operators cannot be used with strings? ( )
A:– B:+ C:* D:All of the mentioned
答案:AI参考:正确答案是【C:*】。\n\n运算符不能用于字符串的是乘法运算符(*)。其他选项中,减号(-)可用于字符串的减法运算,加号(+)可用于字符串的和运算,而所有提到的运算符都可以用于字符串运算。因此,答案为C。'
2.What will be the output of the following Python code ?
print('ab\ncd\nef'.splitlines()) ( )
A:[‘ab ’, ‘cd ’, ‘ef’] B:[‘ab ’, ‘cd ’, ‘ef ’] C:[‘ab’, ‘cd’, ‘ef ’] D:[‘ab’, ‘cd’, ‘ef’]
答案:"AI参考:正确选项是【D:[‘ab’, ‘cd’, ‘ef’]】。 解释:Python中的splitlines()函数会将字符串按照换行符进行分割,返回一个列表,列表中的每个元素都是原字符串中对应位置的子串。在这个例子中,字符串ab cd ef中有三个换行符,因此会被分割成三个子串,即ab、cd和ef。因此,输出结果为[ab, cd, ef]。"
3.Which one of the following functions will return the symmetric difference between two sets, x and y? ( )
A:x ^ y B:x | y C:x – y D:x & y
答案:AI参考:正确答案是 C:x – y 。这个操作符将会返回两个集合x和y之间的对称差,即两者共有部分之外的部分。在编程语言中,C选项的“–”操作符通常用于这种目的。而A选项的“^”通常用于集合的并集操作,B选项的“|”通常用于集合的交集操作,D选项的“&”通常用于位运算。'
4.What is the usage of the zeros() function in Numpy array? ( )
A:To make a Matrix with all diagonal element 0 B:To make a Matrix with first row 0 C:None of the above D:To make a Matrix with all element 0
答案:AI参考:正确答案是D:To make a Matrix with all element 0。\n在Numpy数组中,zeros()函数的作用是创建一个全零矩阵,即所有元素都是0。因此,选项D是正确的。选项A、B和C都不是zeros()函数的正确用法。'
5.

Assume that when x<0, y=x-1; when x=0, y=x and when x>0, y=x+1.
Which one below makes the same effect? ( )


A: B: C: D:
答案:AI参考:正确答案是:C: x<0时,y=x+1;x=0时,y=x;x>0时,y=x-1。\n选项C符合题目条件,因此为正确答案。A、B、D选项均与题目条件不符。'
6.Bitwise _________ gives 1 if one of the bits is 1 and the other is 0. ( )
A:OR B:AND C:XOR D:NOT
答案:AI参考:答案:B\n推理过程:题目中描述的是位与运算,只有位与运算(AND)符合题意。选项A是位或运算(OR),选项C是位异或运算(XOR),选项D是位非运算(NOT)。只有B与题意相符,因此选择B选项。'
7.Which one is wrong about complex numbers in Python? ( )
A:The syntax for expressing complex numbers is real+image j. B:Both the real and imaginary parts are integers. C:Complex numbers can only be compared by == (not > or <). D:The imaginary part must be suffixed with j and j is not case sensitive.
答案:AI参考:正确答案是:B:Both the real and imaginary parts are integers.。\n\nPython中表示复数的语法是real+imagj,复数的实部和虚部可以是整数也可以是浮点数,因此选项A和D都是正确的。复数可以进行比较,但不能只通过==进行比较,因此选项C也是正确的。因此,唯一错误的是选项B,即复数的实部和虚部都是整数。'
8.A body statements in Python is expressed by indentation, such as (if, else, while) end with a colon ":", and then the body statements must be indented (____) spaces. ( )
A:At least 4 B:At least 1 C:Up to 4 D:Must be 2
答案:AI参考:选项A:At least 4\n\n在Python中,代码块的缩进非常重要,用于表示代码块的层次结构。在if、else、while等语句中,语句体需要用缩进来表示其包含的代码块。通常情况下,语句体的缩进至少需要4个空格,这样可以清晰地表示代码的层次结构,提高代码的可读性和可维护性。因此,正确答案是A:至少4个空格。'
9.Which one will output the result “python”and “java”: ( )
A: if False: print("python") print("java") B: if True: print("python") print("java") C: if True: print("python") print("java") D: if True: print("python") print("java")
答案:AI参考:正确选项是D: if True: print("python") print("java")。\n\n解释:这个问题实际上是在询问哪种代码块将会输出 "python" 和 "java" 的结果。在这个情况下,我们要确保的条件语句必须是 "True" 的部分会被执行,这样才能打印出 "python",然后再打印出 "java"。而其他选项 A、B、C 都是把 "False" 的部分也作为了执行条件,这就会导致结果不是预期的 "python" 和 "java"。只有选项 D 符合这个条件,所以答案是 D。'
10.Which of the following dictionary definition will report an error (): ( )

答案:AI参考:基于题目,我会在提供答案前给出必要的背景和答案可能。字典通常记录词语的释义,一般给出正确或相对正确的解释。但在实际操作中,有时候可能会有错误或者一些输入数据的不准确性导致的错误。\n\n所以,对于这个问题,答案可能取决于具体的字典和具体的输入数据。\n\n然而,根据一般的字典定义规则,我无法确定哪个选项会报告错误。因为字典定义通常不会直接报告错误,而是给出正确的解释。\n\n所以,基于这个理由,我无法给出答案。\n\n但是,如果你能提供更多的上下文信息,我可能会更好地帮助你。'
11.When was Python first released? ( )
A:1993 B:1992 C:1994 D:1991 12.Which one would The readlines() method returns? ( )
A:str B:a list of single characters C:a list of integers D:a list of lines 13.What is a variable defined inside a function? ( )
A:A local variable B:A global variable C:An automatic variable D:A volatile variable 14.Is it possible to convert the Numpy array to list in Python? ( )
A:No B:None of the above C:Yes D:Sometimes 15.Given code below, what should be the output?
mylist = [34, 56, 29, 73, 19, 62]
mylist.insert(2, 47)
print(mylist[1:][3]) ( )
A:56 B:73 C:29 D:47 16.

In the following program segment, when the value of score is 85, the value of grade is ___   (   )


A:’C’ B:’D’ C:’B’ D:’A’ 17.NumPy provides a function __________ to create sequences of numbers,. ( )
A:aspace B:all of the mentioned C:arange D:aline 18.What is the usange of seek() method in files? ( )
A:none of the mentioned B:sets the file’s previous position at the offset C:sets the file’s current position at the offset D:sets the file’s current position within the file 19.Which ones belong to the basic functions of computer ( )
A:Control B:Data storage, C:Input and output, D:Calculation, 20.What will be the output of the following Python code? print("abc. DEF".capitalize()) ( )
A:abc. def B:AB C:Abc. Def D:Abc. def E:DEF 21.Which one writes the list elements to the file without replacing them.  (   )
A:fo.write(i) B:fo.write(ls) C:fo.writelines(ls) D:fo.writeline(i) 22.Python is a () language. ( )
A:Interpreted language B:Nature language C:High-level language D:Low-level language

温馨提示支付 ¥3.00 元后可查看付费内容,请先翻页预览!
点赞(5) dxwkbang
返回
顶部