2024知到网课 PYTHON语言程序设计(全英)智慧树答案
第一章 单元测试
1、单选题:Which is NOT the main part of computer ( )
A:Cache
B:memory
C:CPU
D:I/O equipment
正确答案:【Cache】
2、多选题:Which symbol can be used for comments in Python ( )
A:“
B:#
C:!
D://
正确答案:【“ ;
#】
3、单选题:The integrated development tool built into Python is ( ).
A:Pycharm
B:Vs code
C:Jupyter
D:IDLE
正确答案:【IDLE】
4、单选题:Which is the correct operator for power(Xy)? ( )
A:None of the mentioned
B:X**y
C:X^^y
D:X^y
正确答案:【X**y】
5、单选题:Which of the following is incorrect? ( )
A:float(4.2)
B:float(“3+5”)
C:float(3)
D:float(“3”)
正确答案:【float(“3+5”)】
第二章 单元测试
1、单选题:Which of the following is an invalid variable? ( )
A:1st_string
B:foo
C:my_string_1
D:_
正确答案:【1st_string】
2、单选题:What will be the output of the following Python code ? not(10<20) and not(10>30) ( )
A:No output
B:False
C:True
D:Error
正确答案:【False】
3、单选题:Which one will return error when accessing the list ‘l’ with 10 elements. ( )
A:l[10]
B:l[0]
C:l[-1]
D:l[-10]
正确答案:【l[10]】
4、单选题:What will be the output of the following Python code? lst=[3,4,6,1,2]lst[1:2]=[7,8]print(lst) ( )
A:[3, 7, 8, 6, 1, 2]
B:[3,[7,8],6,1,2]
C:Syntax error
D:[3,4,6,7,8]
正确答案:【[3, 7, 8, 6, 1, 2]】
5、单选题:Which of the following operations will rightly modify the value of the element? ( )
A:t={‘h’,’e’,’l’,’l’,’o’} t[0]=’H’
B:t=[‘h’,’e’,’l’,’l’,’o’] t[0]=’H’
C:s=’hello’ s[0]=’H’
D:t=(‘h’,’e’,’l’,’l’,’o’) t[0]=’H’
正确答案:【t=[‘h’,’e’,’l’,’l’,’o’] t[0]=’H’】
6、单选题:The following program input data: 95, the output result is? ( )
A:Please enter your score: 95Awesome!Your ability exceeds 85% of people!
B:none of the mentioned
C:Please enter your score: 95Your ability exceeds 85% of people!
D:Please enter your score: 95Awesome!
正确答案:【Please enter your score: 95Awesome!Your ability exceeds 85% of people!】
第三章 单元测试
1、单选题:Which one description of condition in the followings is correct? ( )
A:The condition 24<=28<25 is legal, and the output is True
B:The condition 24<=28<25 is illegal
C:The condition 24<=28<25 is legal, and the output is False
D:The condition 35<=45<75 is legal, and the output is False
正确答案:【The condition 24<=28<25 is legal, and the output is False】
2、单选题:The output of the following program is? ( )
A:python
B:None
C:Python
D:t
正确答案:【None】
3、单选题:for var in ___: ( )
A:”Hello”
B:13.5
C:range(0,10)
D:[1,2,3]
正确答案:【13.5】
4、单选题:After the following program is executed, the value of s is?( )
A:46
B:47
C:9
D:19
正确答案:【9】
5、单选题:Which is the output of the following code?a = 30b = 1if a >=10:a = 20elif a>=20:a = 30elif a>=30:b = aelse:b = 0print(“a=”,a,”b=”,b) ()
A:a=20, b=20
B:a=30, b=1
C:a=20, b=1
D:a=30, b=30
正确答案:【a=20, b=1】
第四章 单元测试
1、单选题:Which keyword is used to define a function in Python? ( )
A:function
B:def
C:define
D:fun
正确答案:【def】
2、单选题:What will be the output of the following Python code? ( )
A:x is 50Changed local x to 2x is now 50
B:None of the mentioned
C:x is 50Changed local x to 2x is now 2
D:x is 50Changed local x to 2x is now 100
正确答案:【x is 50Changed local x to 2x is now 50】
3、多选题:Which are the advantages of functions in Python? ( )
A:Easier to manage the code
B:Reducing duplication of code
C:Decomposing complex problems into simpler pieces
D:Improving clarity of the code
正确答案:【Easier to manage the code;
Reducing duplication of code;
Decomposing complex problems into simpler pieces;
Improving clarity of the code】
4、单选题:How does the variable length argument specified in the function heading? ( )
A:one star followed by a valid identifier
B:two stars followed by a valid identifier
C:two underscores followed by a valid identifier
D:one underscore followed by a valid identifier
正确答案:【one star followed by a valid identifier】
5、单选题:What will be the output of the following Python code? list(map((lambda x:x**2), filter((lambda x:x%2==0), range(10)))) ( )
A:[0, 4, 16, 36, 64]
B:No output
C:[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
D:Error
正确答案:【[0, 4, 16, 36, 64]】
第五章 单元测试
1、单选题:Which of the following statements cannot create a demo.txt file? ( )
A:f = open(“demo.txt”, “w”)
B:f = open(“demo.txt”, “a”)
C:f = open(“demo.txt”, “x”)
D:f = open(“demo.txt”, “r”)
正确答案:【f = open(“demo.txt”, “r”)】
2、单选题:After executing the following procedure, what content will be saved in the file?file=open(‘test.txt’, ‘wt+’)file.write(‘hello SCUT’)file.close()file=open(‘test.txt’, ‘at+’)file.write(‘hello world’)file.close() ( )
A:hello world
B:hello SCUThello world
C:hello SCUT hello world
D:hello SCUT world
正确答案:【hello SCUThello world】
3、单选题:Which function is not the way Python reads files. ( )
A:read()
B:readlines()
C:readline()
D:readtext()
正确答案:【readtext()】
4、单选题:How to rename a file in Python? ( )
A:os.set_name(existing_name, new_name)
B:os.rename(fp, new_name)
C:fp.name = ‘new_name.txt’
D:os.rename(existing_name, new_name)
正确答案:【os.rename(existing_name, new_name)】
5、单选题:What is the usage of tell() function in Python? ( )
A:tells you the current position within the file
B:tells you the file is opened or not
C:tells you the end position within the file
D:none of the mentioned
正确答案:【tells you the current position within the file】
第六章 单元测试
1、单选题:What will be the output of the following Python code? ( )
A:Runs normally, doesn’t display anything
B:Displays 0, which is the automatic default value
C:Reports error as display function requires additional argument
D:Reports error as one argument is required while creating the object
正确答案:【Reports error as one argument is required while creating the object】
2、单选题:What will be the output of the following Python code? ( )
A:Error
B:‘Old’
C:Nothing is printed
D:‘New’
正确答案:【‘Old’】
3、单选题:What will be the output of the following Python code? ( )
A:Exception is thrown
B:__main__
C:test
D:Demo
正确答案:【__main__】
4、单选题:Which one of the followings is not correct about Class hierarchy? ( )
A:Subclass can override the methods inherited from superclass
B:Subclass can have methods with same name as superclass
C:Subclass can inherit all attributes from superclass
D:Subclass can not add more behavior/methods
正确答案:【Subclass can not add more behavior/methods】
5、单选题:What will be the output of the following Python code? ( )
A:0 0
B:0 1
C:Error, the syntax of the invoking method is wrong
D:Error because class B inherits A but variable x isn’t inherited
正确答案:【0 1】
第七章 单元测试
1、单选题:Numpy is a third party package for ____ in Python? ( )
A:Lambda function
B:Type casting
C:Function
D:Array
正确答案:【Array】
2、单选题:How to convert a Numpy array to a list in Python? ( )
A:list(array)
B:list.append(array)
C:array.list
D:list.array
正确答案:【list(array)】
3、单选题:Which keyword is used to access the Numpy package in Python? ( )
A:load
B:from
C:fetch
D:import
正确答案:【import】
4、单选题:Which one is correct syntax for the ‘reshape()’ function in Numpy? ( )
A:reshape(array,shape)
B:reshape(shape,array)
C:array.reshape(shape)
D:reshape(shape)
正确答案:【reshape(array,shape)】
5、单选题:What will be the output for the following code? import numpy as np a = np.array([1, 2, 3], dtype = complex) print(a) ( )
A:[[ 1.+0.j, 2.+0.j, 3.+0.j]]
B:[ 1.+0.j]
C:[ 1.+0.j, 2.+0.j, 3.+0.j]
D:Error
正确答案:【[ 1.+0.j, 2.+0.j, 3.+0.j]】
如有任何疑问请及时联系QQ 50895809反馈