education
-Python Programming based - Chapter materials, examination materials - Nankai University 【】
1-01 unit testing
1、【 Single topic selection 】Python Advantages do not include ( ).
A、 Easy to learn
B、 Free and open source
C、 Rich library
D、 Force indent
Reference material 【 】
2、【 Single topic selection 】 Use Python When programming the system , utilize ( ) It is convenient to maintain and manage the system .
A、API
B、Tkinter/PyQT
C、Numpy
D、DB-API
Reference material 【 】
1-02 unit testing
1、【 Single topic selection 】( ) It is the most basic operation completed by the computer .
A、 Program
B、 Instructions
C、 Code
D、 command
Reference material 【 】
2、【 Single topic selection 】Python After the program is executed once, it will automatically generate a program with an extension of ( ) Bytecode file , To improve operational efficiency .
A、.py
B、.pyc
C、.pyb
D、.pyf
Reference material 【 】
3、【 Judgment questions 】Python The prompt for the locale is .
A、 correct
B、 error
Reference material 【 】
1-03 unit testing
1、【 Single topic selection 】 stay Python Directly enter... At the prompt of programming environment Python The way code is run and executed is called ( ).
A、 Interactive operation
B、 Script run
C、 Run in code
D、 Instant operation
Reference material 【 】
2、【 Single topic selection 】Python3.x The environment create Python Script file , You need to set the file encoding format to ( ).
A、ANSI
B、GBK
C、UTF-8
D、UNICODE
Reference material 【 】
3、【 Judgment questions 】 The function of annotations is to enhance the readability of the program , Will not actually run .
A、 correct
B、 error
Reference material 【 】
1-04 unit testing
1、【 Single topic selection 】 In the following options , Used to receive standard input data ( That is, input from the keyboard )、 Return to string type ( character string ) The function of is ( ).
A、eval
B、input
C、print
D、get
Reference material 【 】
2、【 Single topic selection 】 In the following options , Used to convert various types of data ( character string 、 Integers 、 Floating point numbers 、 list 、 Dictionary, etc ) The function output to the screen is ( ).
A、eval
B、input
C、print
D、get
Reference material 【 】
3、【 Judgment questions 】 Debugging is to solve syntax errors .
A、 correct
B、 error
Reference material 【 】
Chapter 1 unit test
1、【 Single topic selection 】Python After the program is executed once, it will automatically generate a program with an extension of ( ) Bytecode file , To improve operational efficiency .
A、.py
B、.pyc
C、.pyb
D、.pyf
Reference material 【 】
2、【 Single topic selection 】Python3.x The environment create Python Script file , You need to set the file encoding format to ( ).
A、ANSI
B、GBK
C、UTF-8
D、UNICODE
Reference material 【 】
3、【 Single topic selection 】 In the following options , Used to convert various types of data ( character string 、 Integers 、 Floating point numbers 、 list 、 Dictionary, etc ) The function output to the screen is ( ).
A、eval
B、input
C、print
D、get
Reference material 【 】
4、【 Multiple choice 】Python It's a kind of ( ) Language .
A、 Compiler language
B、 Explanatory language
C、 High-level language
D、 Low level language
Reference material 【 】
5、【 Multiple choice 】Python The operation modes of include ( ).
A、 Interactive operation
B、 Script run
C、 Run in code
D、 Instant operation
Reference material 【 】
6、【 Multiple choice 】Python Program usage ( ) Make multiple line comments .
A、 Three consecutive single quotes
B、 Three consecutive double quotes
C、 A semicolon
D、 Well No
Reference material 【 】
7、【 Multiple choice 】 In the following options , Belong to IDLE The of window mode is ( ).
A、Shell
B、Script
C、Editor
D、Window
Reference material 【 】
8、【 Judgment questions 】 Interpretation is to translate all the source code into machine instructions , Plus some descriptive information , Generate executable files .
A、 correct
B、 error
Reference material 【 】
9、【 Judgment questions 】Python Each statement in the program ends with a semicolon .
A、 correct
B、 error
Reference material 【 】
10、【 Judgment questions 】 When the program encounters a breakpoint during execution, the execution is suspended , And you can view the current status of each variable .
A、 correct
B、 error
Reference material 【 】
2-01 unit testing
1、【 Single topic selection 】 In the following options ,( ) Is not a constant .
A、12
B、35.7
C、‘Python’
D、abc
Reference material 【 】
2、【 Single topic selection 】 Pass statement “m,n=3,5”, Defined ( ) A variable .
A、0
B、1
C、2
D、 Report errors
Reference material 【 】
3、【 Judgment questions 】Python Variables in must be defined before use .
A、 correct
B、 error
Reference material 【 】
2-02 unit testing
1、【 Single topic selection 】 perform “print(0o20)”, Then... Will be output on the screen ( ).
A、20
B、0o20
C、16
D、32
Reference material 【 】
2、【 Single topic selection 】 perform “print(0x20)”, Then... Will be output on the screen ( ).
A、20
B、0x20
C、16
D、32
Reference material 【 】
3、【 Judgment questions 】1.25e3 Represents a floating point number 1250.0 Scientific notation representation of .
A、 correct
B、 error
Reference material 【 】
2-03 unit testing
1、【 Single topic selection 】 In the following options , The statements that will report errors during execution are ( ).
A、int(‘23’)
B、int(‘23+1’)
C、int(‘23’,8)
D、int(‘2a’,16)
Reference material 【 】
2、【 Single topic selection 】 In the following options , The statement that will not report an error during execution is ( ).
A、int(‘23.5’)
B、float(‘23.5+1’)
C、float(‘23.5’)
D、int(‘2a’,8)
Reference material 【 】
3、【 Judgment questions 】 It is known that s= Study , execute s[0]=‘ complex ’ after s The string stored in is modified to “ review ”.
A、 correct
B、 error
Reference material 【 】
2-04 unit testing
1、【 Single topic selection 】 In the following options , The option to describe the error is ( ).
A、 The element types in the list must be the same
B、 The elements in the list are separated by commas
C、 The elements in the list can be list types
D、 The list can contain elements of numeric type
Reference material 【 】
2、【 Single topic selection 】 It is known that ls=[12,34.5,True,‘test’,3+5j], Then... Of the following options , The output is “[‘test’]” The options are ( ).
A、ls[3]
B、ls[4]
C、ls[3:4]
D、ls[4:5]
Reference material 【 】
3、【 Judgment questions 】 By subscript “[]” Not only can you access an element in the list , You can also modify elements .
A、 correct
B、 error
Reference material 【 】
2-05 unit testing
1、【 Single topic selection 】 It is known that t=(12,34.5,True,‘test’,3+5j), Then... Of the following options , The output is “(‘test’,)” The options are ( ).
A、t[3]
B、t[4]
C、t[3:4]
D、t[4:5]
Reference material 【 】
2、【 Multiple choice 】 It is known that t=(12,1.5,[True,3+5j]), Then... Of the following options , Statements that will not report errors during execution include ( ).
A、t[2]=1
B、t[2:]=1
C、t[2][1]=‘test’
D、print(t[2])
Reference material 【 】
3、【 Judgment questions 】 By subscript “[]” Not only can you access an element in a tuple , You can also modify elements .
A、 correct
B、 error
Reference material 【 】
2-06 unit testing
1、【 Single topic selection 】 In the following options , The statements that will report errors during execution are ( ).
A、set(‘Python’)
B、set(35.2,True)
C、set([35.2,True])
D、set((35.2,True))
Reference material 【 】
2、【 Single topic selection 】 In the following options , The statement that will not report an error during execution is ( ).
A、{[‘Python’,True]}
B、{3.5,[1.2,True]}
C、{3.5,{1.2,True}}
D、{3.5,1.2,True}
Reference material 【 】
3、【 Judgment questions 】 adopt “{}” You can create an empty collection .
A、 correct
B、 error
Reference material 【 】
2-07 unit testing
1、【 Single topic selection 】 In the following options , The wrong description is ( ).
A、 Every element in the dictionary is a key : It's worth it
B、 The keys of different elements in the dictionary cannot be the same
C、 The values of different elements in the dictionary cannot be the same
D、 adopt “{}” You can create an empty dictionary
Reference material 【 】
2、【 Single topic selection 】 In the following options , The statement that cannot create a dictionary object is ( ).
A、{‘one’:1, ‘two’:2, ‘three’:3}
B、dict(‘one’:1, ‘two’:2, ‘three’:3)
C、dict([(‘one’,1), (‘two’,2), (‘three’,3)])
D、dict(zip([‘one’,‘two’,‘three’], [1,2,3]))
Reference material 【 】
2-08 unit testing
1、【 Single topic selection 】 In the following placeholder operators , The placeholder for a signed integer decimal number is ( ).
A、%d
B、%%
C、%f
D、%s
Reference material 【 】
2、【 Single topic selection 】34 The result is ( ).
A、12
B、81
C、7
D、 Report errors
Reference material 【 】
2-09 unit testing
1、【 Single topic selection 】 In the following options , Can be used to judge c The expression of whether the characters saved in are English letters is ( ).
A、c>=‘a’ and c<=‘Z’
B、c>=‘A’ and c<=‘z’
C、c>=‘a’ and c<=‘z’ and c>=‘A’ and c<=‘Z’
D、c>=‘a’ and c<=‘z’ or c>=‘A’ and c<=‘Z’
Reference material 【 】
2、【 Single topic selection 】 It is known that a=15, execute “a%=6” after ,a The value of is ( ).
A、15
B、2.5
C、3
D、2
Reference material 【 】
2-10 unit testing
1、【 Single topic selection 】 Decimal number 37 Convert to binary number and the result is ( ).
A、100101B
B、101001B
C、100100B
D、100001B
Reference material 【 】
2、【 Single topic selection 】7^10 The result is ( ).
A、17
B、15
C、13
D、2
Reference material 【 】
2-11 unit testing
1、【 Single topic selection 】 The program is running , Both input and output data are stored in ( ) in .
A、 External storage
B、 Memory
C、CPU
D、 Hard disk
Reference material 【 】
2、【 Single topic selection 】 In the following options , The return result is True The expression of is ( ).
A、1 in {‘ab’:1}
B、‘ab’ in ‘abc’
C、‘ac’ in ‘abc’
D、‘ab’ in [‘abc’,1]
Reference material 【 】
2-12 unit testing
1、【 Single topic selection 】3*52 The result is ( ).
A、30
B、225
C、75
D、 Report errors
Reference material 【 】
2、【 Single topic selection 】 It is known that x=5, execute “x*=3+6” after ,x The value of is ( ).
A、15
B、21
C、45
D、 Report errors
Reference material 【 】
3、【 Judgment questions 】 expression a=b=1 The operation order of the two operators in is from right to left .
A、 correct
B、 error
Reference material 【 】
2-13 unit testing
1、【 Single topic selection 】 When drawing a flowchart , Conditional judgment should be placed on ( ) in .
A、 Rounded rectangle
B、 round
C、 Rectangle box
D、 Diamond frame
Reference material 【 】
2、【 Single topic selection 】 When drawing a flowchart , Only ( ) Multiple branches are allowed after .
A、 Rounded rectangle
B、 round
C、 Rectangle box
D、 Diamond frame
Reference material 【 】
3、【 Judgment questions 】 Pseudocode must conform to Python The grammatical requirements of language .
A、 correct
B、 error
Reference material 【 】
2-14 unit testing
1、【 Single topic selection 】 The output of the following program is ( ).score=80if score60: print(‘ The result is %d’%score, end=’,’)print(‘ fail, ’)
A、 The result is 80, fail,
B、 The result is 80
C、 fail,
D、 There is no output
Reference material 【 】
2、【 Single topic selection 】 The output of the following program is ( ).score=80if score60: print(‘ fail, ’)else: pass
A、 fail,
B、pass
C、 Report errors
D、 There is no output
Reference material 【 】
2-15 unit testing
1、【 Single topic selection 】 It's known that there's code “for x in y:”, be y It must be a ( ).
A、 Hashable object
B、 Iteratable object
C、 List objects
D、 A collection of objects
Reference material 【 】
2、【 Judgment questions 】print(list(range(5))) The output of is “[0, 1, 2, 3, 4] ”.
A、 correct
B、 error
Reference material 【 】
2-16 unit testing
1、【 Single topic selection 】 The output of the following program is ( ).m=5while(m0): m-=1print(m)
A、0
B、4
C、5
D、-1
Reference material 【 】
2、【 Judgment questions 】 It is known that t=(5,10,15), be list(range(len(t))) The output of is [1, 2, 3].
A、 correct
B、 error
Reference material 【 】
2-17 unit testing
1、【 Single topic selection 】 The command to jump out of the loop is ( ).
A、break
B、continue
C、else
D、pass
Reference material 【 】
2、【 Single topic selection 】 The command to end this cycle and start the next cycle is ( ).
A、break
B、continue
C、else
D、pass
Reference material 【 】
Chapter two Programming practice 2
Chapter two Programming practice
Chapter two Programming practice ( The first 2 Take turns to supplement )
Chapter 2 unit test
1、【 Single topic selection 】 perform “print(0o20)”, Then... Will be output on the screen ( ).
A、20
B、0o20
C、16
D、32
Reference material 【 】
2、【 Single topic selection 】 In the following options , The statements that will report errors during execution are ( ).
A、int(‘23’)
B、int(‘23+1’)
C、int(‘23’,8)
D、int(‘2a’,16)
Reference material 【 】
3、【 Single topic selection 】 It is known that ls=[12,34.5,True,‘test’,3+5j], Then... Of the following options , The output is “[‘test’]” The options are ( ).
A、ls[3]
B、ls[4]
C、ls[3:4]
D、ls[4:5]
Reference material 【 】
4、【 Single topic selection 】 In the following options , The statement that cannot create a dictionary object is ( ).
A、{‘one’:1, ‘two’:2, ‘three’:3}
B、dict(‘one’:1, ‘two’:2, ‘three’:3)
C、dict([(‘one’,1), (‘two’,2), (‘three’,3)])
D、dict(zip([‘one’,‘two’,‘three’], [1,2,3]))
Reference material 【 】
5、【 Single topic selection 】 The output of the following program is ( ).score=80if score60: print(‘ The result is %d’%score, end=’,’)print(‘ fail, ’)
A、 The result is 80, fail,
B、 The result is 80
C、 fail,
D、 There is no output
Reference material 【 】
6、【 Multiple choice 】 It's known that there's code “for x in y:”, be y The data type can be ( ).
A、 list
B、 Tuples
C、 The number
D、 character string
Reference material 【 】
7、【 Multiple choice 】 In the following options ,+ The expression used as a splice operator is ( ).
A、[1.2]+[2.5]
B、1.2+2.5
C、‘abc’+‘def’
D、[1.2+2.5]
Reference material 【 】
8、【 Multiple choice 】 In the following options , Can be used to judge x and y Whether the statement corresponding to the same storage unit is ( ).
A、xy
B、x is y
C、id(x)id(y)
D、not x!=y
Reference material 【 】
9、【 Multiple choice 】 It is known that the value of a binary bit of two numbers is 0 and 1, The value of the result bit is 1, Then the bit operation being done may be ( ).
A、^
B、|
C、&
D、~
Reference material 【 】
10、【 Multiple choice 】 In the following placeholder operators , The placeholder for a signed floating-point decimal number is ( ).
A、%f
B、%d
C、%F
D、%s
Reference material 【 】
11、【 Judgment questions 】 It is known that s= Study , execute s[0]=‘ complex ’ after s The string stored in is modified to “ review ”.
A、 correct
B、 error
Reference material 【 】
12、【 Judgment questions 】 By subscript “[]” Not only can you access an element in a tuple , You can also modify elements .
A、 correct
B、 error
Reference material 【 】
13、【 Judgment questions 】 perform “print(’%.2f%%’% 52.50)”, The output is “52.50%”.
A、 correct
B、 error
Reference material 【 】
14、【 Judgment questions 】 The rule for converting binary numbers to decimal numbers is “ To sum by right ”.
A、 correct
B、 error
Reference material 【 】
15、【 Judgment questions 】print(list(range(5))) The output of is “[0, 1, 2, 3, 4] ”.
A、 correct
B、 error
Reference material 【 】
3-01 Classroom tests
1、【 Single topic selection 】 When completing a more complex task , We usually decompose the task into several sub tasks , Gradually achieve the overall goal of the task by completing these subtasks , The programming method adopting this idea is called ( ) Programming method .
A、 object-oriented
B、 Class oriented
C、 structured
D、 Decomposition
Reference material 【 】
2、【 Judgment questions 】Python The function definition in is through define Keyword complete .
A、 correct
B、 error
Reference material 【 】
3-02 In class testing
1、【 Single topic selection 】 When defining a function, the parameters given in a pair of parentheses after the function name are called ( ).
A、 Actual parameters
B、 Shape parameter
C、 Type parameter
D、 Name parameter
Reference material 【 】
2、【 Single topic selection 】 When calling a function, the parameters given in a pair of parentheses after the function name are called ( ).
A、 Actual parameters
B、 Shape parameter
C、 Type parameter
D、 Name parameter
Reference material 【 】
3-03 In class testing
1、【 Single topic selection 】 The output of the following program is ( ).def StudentInfo(country=‘ China ’,name): print(’%s,%s’%(name,country))StudentInfo(‘ The United States ’,‘ David ’)
A、 David , The United States
B、 The United States , David
C、 David , China
D、 Report errors
Reference material 【 】
2、【 Judgment questions 】 For formal parameters without default parameter values , Arguments must be specified for a function call .
A、 correct
B、 error
Reference material 【 】
3-04 In class testing
1、【 Single topic selection 】 Indefinite length positional parameters are encapsulated as ( ).
A、 Tuples
B、 list
C、 aggregate
D、 Dictionaries
Reference material 【 】
2、【 Judgment questions 】 For a function with an indefinite length parameter , Its normal parameters can have default parameter values .
A、 correct
B、 error
Reference material 【 】
3-05 In class testing
1、【 Single topic selection 】 Known function calls Fun(**a), be a May be ( ).
A、 Tuples
B、 list
C、 aggregate
D、 Dictionaries
Reference material 【 】
2、【 Judgment questions 】 The result of dictionary splitting is as keyword parameter .
A、 correct
B、 error
Reference material 【 】
3-06 In class testing
1、【 Single topic selection 】 Return the operation result of a function to the place where the function is called , You should use ( ).
A、print
B、return
C、break
D、continue
Reference material 【 】
2、【 Judgment questions 】 If you don't write explicitly in a function return sentence , Then the function has an implicit function that does not return any data retrun sentence .
A、 correct
B、 error
Reference material 【 】
3-07 In class testing
1、【 Single topic selection 】 When you want to use some functions in a module , We can go through ( ) Statement to import the module into .
A、include
B、import
C、export
D、load
Reference material 【 】
2、【 Judgment questions 】 adopt import Statement can only import one module at a time .
A、 correct
B、 error
Reference material 【 】
3-08 In class testing
1、【 Single topic selection 】 A script file M.py When executed separately , Its __name__ The value of the variable is ( ).
A、M
B、main
C、M.py
D、 non-existent
Reference material 【 】
2、【 Judgment questions 】 Each module has a global variable __name__.
A、 correct
B、 error
Reference material 【 】
3-09 In class testing
1、【 Single topic selection 】 It is known that M There is a parameterless function in the module fun, And in the script file N.py There is “from M import fun”, It's in N.py Call in M Module fun The method of the function is ( ).
A、fun()
B、N.fun()
C、M.fun()
D、N.M.fun()
Reference material 【 】
2、【 Judgment questions 】 It is known that M There are two functions in the module f1 and f2, In the script file N.py Pass through “from M import *” Must be able to M Module f1 and f2 Import .
A、 correct
B、 error
Reference material 【 】
3-10 In class testing
1、【 Single topic selection 】 Known in script files N.py There are function calls in “A.B.C.d()”, be import The correct way to write a sentence is ( ).
A、from A.B import C
B、from A.B.C import d
C、import A.B.C
D、import A.B.C.d
Reference material 【 】
2、【 Judgment questions 】 Modules can be placed in any package or sub package .
A、 correct
B、 error
Reference material 【 】
3-11 In class testing
1、【 Single topic selection 】 The acquisition and installation of third-party modules can use ( ) Tools .
A、pip
B、get
C、install
D、setup
Reference material 【 】
2、【 Judgment questions 】 Monkey patch refers to the dynamic replacement of existing code at run time , Without modifying the original code .
A、 correct
B、 error
Reference material 【 】
3-12 In class testing
1、【 Single topic selection 】 The variables defined in a function are ( )
A、 local variable
B、 Global variables
C、 Static variables
D、 The function variables
Reference material 【 】
2、【 Judgment questions 】 Variables defined in one function cannot be used in another function .
A、 correct
B、 error
Reference material 【 】
3-13 In class testing
1、【 Single topic selection 】 Variables defined outside all functions are ( ).
A、 local variable
B、 Global variables
C、 Static variables
D、 File variables
Reference material 【 】
2、【 Judgment questions 】 Variables defined outside all functions are global variables .
A、 correct
B、 error
Reference material 【 】
3-14 In class testing
1、【 Single topic selection 】 The inner function uses the variables defined in the outer function , You should use ( ) keyword .
A、local
B、nonlocal
C、global
D、nonglobal
Reference material 【 】
2、【 Judgment questions 】 The inner function uses the variables defined by the outer function , You have to use nonlocal keyword .
A、 correct
B、 error
Reference material 【 】
3-15 In class testing
1、【 Single topic selection 】 Recursive functions refer to ( ).
A、 Solve the problem by calling yourself inside a function
B、 Solve the problem by calling other functions within a function
C、 A function is constantly called by other functions to solve the problem
D、 A function that takes a function as an argument
Reference material 【 】
2、【 Judgment questions 】 For computing 1+2+…+n The question of , You can design recursive functions to solve .
A、 correct
B、 error
Reference material 【 】
3-16 In class testing
1、【 Single topic selection 】 Higher order functions refer to ( ).
A、 Solve the problem by calling yourself inside a function
B、 Solve the problem by calling other functions within a function
C、 A function is constantly called by other functions to solve the problem
D、 A function that takes a function as an argument
Reference material 【 】
2、【 Judgment questions 】lambda Functions can be passed as arguments to the formal parameters of higher-order functions .
A、 correct
B、 error
Reference material 【 】
3-17 In class testing
1、【 Single topic selection 】 For closure , Variables defined in the outer function but used by the inner function are called ( ).
A、 Outer variable
B、 Closure variables
C、 Free variable
D、 Constraint variables
Reference material 【 】
2、【 Judgment questions 】 The local variables defined in the outer function are used by the inner function , Then every time the outer function is called, it will form a closure .
A、 correct
B、 error
Reference material 【 】
3-18 In class testing
1、【 Multiple choice 】 In the following options , The right description is ( ).
A、 A decorator can inject code into multiple functions
B、 A decorator can only inject code into one function
C、 A function can inject code into multiple decorators
D、 A function can only inject the code of one decorator
Reference material 【 】
2、【 Judgment questions 】 The modifier does not inject the existing function into the existing code .
A、 correct
B、 error
Reference material 【 】
The third chapter Programming practice
The third chapter Programming practice ( The first 2 Take turns to supplement )
Chapter 3 unit test
1、【 Single topic selection 】 When completing a more complex task , We usually decompose the task into several sub tasks , Gradually achieve the overall goal of the task by completing these subtasks , The programming method adopting this idea is called ( ) Programming method .
A、 object-oriented
B、 Class oriented
C、 structured
D、 Decomposition
Reference material 【 】
2、【 Single topic selection 】 When defining a function, the parameters given in a pair of parentheses after the function name are called ( ).
A、 Actual parameters
B、 Shape parameter
C、 Type parameter
D、 Name parameter
Reference material 【 】
3、【 Single topic selection 】 The output of the following program is ( ).def StudentInfo(country=‘ China ’,name): print(’%s,%s’%(name,country))StudentInfo(‘ The United States ’,‘ David ’)
A、 David , The United States
B、 The United States , David
C、 David , China
D、 Report errors
Reference material 【 】
4、【 Single topic selection 】 Indefinite length positional parameters are encapsulated as ( ).
A、 Tuples
B、 list
C、 aggregate
D、 Dictionaries
Reference material 【 】
5、【 Single topic selection 】 Known function calls Fun(**a), be a May be ( ).
A、 Tuples
B、 list
C、 aggregate
D、 Dictionaries
Reference material 【 】
6、【 Single topic selection 】 Return the operation result of a function to the place where the function is called , You should use ( ).
A、print
B、return
C、break
D、continue
Reference material 【 】
7、【 Single topic selection 】 When you want to use some functions in a module , We can go through ( ) Statement to import the module into .
A、include
B、import
C、export
D、load
Reference material 【 】
8、【 Single topic selection 】 A script file M.py When executed separately , Its __name__ The value of the variable is ( ).
A、M
B、main
C、M.py
D、 non-existent
Reference material 【 】
9、【 Single topic selection 】 The scope of the global variable is ( ).
A、 From the position where the variable is defined to the end of the file
B、 From the position where the variable is defined to the end of the function
C、 All functions
D、 Whole procedure
Reference material 【 】
10、【 Single topic selection 】 For closure , Variables defined in the outer function but used by the inner function are called ( ).
A、 Outer variable
B、 Closure variables
C、 Free variable
D、 Constraint variables
Reference material 【 】
11、【 Multiple choice 】 In the following options , The wrong description is ( ).
A、 The formal and actual parameter names of the function must be exactly the same
B、 Assigning a value to a formal parameter in the function body will affect the value of the corresponding argument
C、 If the argument is an object such as a list , You can modify the value of the corresponding element in the argument list through formal parameters in the function body
D、 When there are multiple formal parameters , The formal parameters are separated by commas
Reference material 【 】
12、【 Multiple choice 】 In the following options , The wrong description is ( ).
A、 For formal parameters with default parameter values , You can call a function without passing arguments
B、 For formal parameters that do not specify a default parameter value , If you don't pass an argument to a function call , Then the value of the formal parameter is None
C、 For formal parameters with default parameter values , If you specify arguments for a function call , Then the formal parameter uses the passed in argument value
D、 If multiple formal parameters have default parameter values , When the function is called, these formal parameters either use the default parameter value or use the passed in argument value
Reference material 【 】
13、【 Multiple choice 】 It is known that M There are two functions in the module f1 and f2, In the script file N.py To import M Modular f1 and f2, The correct way to write it is ( ).
A、from M import f1,f2
B、from M import f1 and f2
C、from M import *
D、from M import f1 as f2
Reference material 【 】
14、【 Multiple choice 】 In the following options , Local variables are ( ).
A、 Variables defined in functions
B、 The formal parameter of the function
C、 Variables defined outside functions
D、 Function name
Reference material 【 】
15、【 Multiple choice 】 In the following options , The right description is ( ).
A、 The function body of one function can contain the definition of another function
B、 The function body of one function can contain the call of another function
C、 The function body of a function cannot contain the definition of another function
D、 The function body of a function cannot contain the call of another function
Reference material 【 】
16、【 Judgment questions 】 Interpretation is to translate all the source code into machine instructions , Plus some descriptive information , Generate executable files .
A、 correct
B、 error
Reference material 【 】
17、【 Judgment questions 】Python Each statement in the program ends with a semicolon .
A、 correct
B、 error
Reference material 【 】
18、【 Judgment questions 】 adopt “{}” You can create an empty collection .
A、 correct
B、 error
Reference material 【 】
19、【 Judgment questions 】 The rule for converting binary numbers to decimal numbers is “ To sum by right ”.
A、 correct
B、 error
Reference material 【 】
20、【 Judgment questions 】 The outer function defines the local variable x, If the inner function only gets x Value 、 Don't modify x Value , You can not use nonlocal keyword .
A、 correct
B、 error
Reference material 【 】
4-01 In class tests
1、【 Single topic selection 】 The basic idea of object-oriented method is that all systems are composed of ( ) constitute .
A、 class
B、 object
C、 function
D、 Method
Reference material 【 】
2、【 Judgment questions 】 Using one class, you can create multiple objects , And each object can store different data .
A、 correct
B、 error
Reference material 【 】
4-02 In class tests
1、【 Single topic selection 】 Class ( ) The corresponding class can be used to store what data .
A、 attribute
B、 Method
C、 data
D、 object
Reference material 【 】
2、【 Judgment questions 】 Class encapsulation refers to encapsulating a data related attribute together .
A、 correct
B、 error
Reference material 【 】
4-03 In class tests
1、【 Single topic selection 】 It is known that Student Class is an empty class , Through “Student.name=‘unknown’” Statement can be added through ( ) visit .
A、 Class name or object name
B、 Class name only
C、 Only object names
D、 cannot access
Reference material 【 】
2、【 Judgment questions 】 Dynamically bind new properties for an object , Can only be accessed through this object .
A、 correct
B、 error
Reference material 【 】
4-04 In class tests
1、【 Single topic selection 】 The first parameter corresponds to the method of the instance object of the class ( ).
A、 Class method
B、 Static methods
C、 Built-in methods
D、 Common method
Reference material 【 】
2、【 Judgment questions 】 Common methods of known classes func Yes 3 There are two formal parameters and none of them has a default parameter value , The corresponding... Must be passed in when calling this method 3 An argument .
A、 correct
B、 error
Reference material 【 】
4-05 In class tests
1、【 Single topic selection 】 We know that the name of a class attribute is __id, Then the attribute is ( ).
A、 Built in properties
B、 Private property
C、 General attribute
D、 External properties
Reference material 【 】
2、【 Judgment questions 】 It is known that Student Class has an attribute __id,stu yes Student Class object , Through “stu.__id=‘1810101’” Can be stu Object __id Property is assigned to a string ’1810101’.
A、 correct
B、 error
Reference material 【 】
4-06 In class tests
1、【 Single topic selection 】 The method name of the constructor is ( ).
A、construct
B、init
C、begin
D、start
Reference material 【 】
2、【 Judgment questions 】 Constructors can have no formal parameters .
A、 correct
B、 error
Reference material 【 】
4-07 In class tests
1、【 Single topic selection 】 The method name of the destructor method is ( ).
A、destruct
B、term
C、del
D、end
Reference material 【 】
2、【 Judgment questions 】 Destruct methods can have no formal parameters .
A、 correct
B、 error
Reference material 【 】
4-08 In class tests
1、【 Single topic selection 】 It is known that stu yes Student Class object , execute “print(stu)” Will automatically execute Student Class ( ) Method .
A、init
B、str
C、format
D、print
Reference material 【 】
2、【 Judgment questions 】__str__ The return value of the method can be an integer .
A、 correct
B、 error
Reference material 【 】
4-09 In class tests
1、【 Single topic selection 】 If a class C1 By inheriting existing classes C And create , Will C1 Referred to as ( ).
A、 Subclass
B、 Base class
C、 Parent class
D、 Superclass
Reference material 【 】
2、【 Judgment questions 】 Creating new classes based on existing classes is polymorphism in object-oriented .
A、 correct
B、 error
Reference material 【 】
4-10 In class tests
1、【 Single topic selection 】 If you have A and B Define subclasses as parent classes C, The definition is C The correct way to write the first line of code is ( ).
A、class C:A,B
B、class C:A,C:B
C、class C(A,B)
D、class C(A),C(B)
Reference material 【 】
2、【 Judgment questions 】 It is known that A Class defines the method fa1 and fa2,B Class defines the method fb,A yes B Subclasses of , be B Class contains 3 A way .
A、 correct
B、 error
Reference material 【 】
4-11 In class tests
1、【 Single topic selection 】 In the case of executing the same code , The system will call the methods in the corresponding class according to the class to which the object actually belongs , This feature is class ( ).
A、 encapsulation
B、 inheritance
C、 polymorphism
D、 Self adaptability
Reference material 【 】
2、【 Judgment questions 】 Method rewriting means that a subclass can redefine the methods inherited from the parent class , Thus, the subclass object can behave differently from the parent object .
A、 correct
B、 error
Reference material 【 】
4-12 In class tests
1、【 Single topic selection 】 The method used to get the parent proxy object is ( ).
A、parent
B、proxy
C、delegate
D、super
Reference material 【 】
2、【 Judgment questions 】 Using the parent class object that you get, you can call the parent class method that is overridden in the subclass. .
A、 correct
B、 error
Reference material 【 】
4-13 In class tests
1、【 Single topic selection 】 Judge whether the class to which an object belongs is a specified class or a subclass of a specified class , Built in functions should be used ( ).
A、isinstance
B、issubclass
C、type
D、isclass
Reference material 【 】
2、【 Judgment questions 】 It is known that B yes A Parent class of ,a yes A Class object ,b yes B Class object , be “isinstance(a,type(b))” The return result is True.
A、 correct
B、 error
Reference material 【 】
4-14 In class tests
1、【 Single topic selection 】 Class methods refer to the use of ( ) The method of decoration .
A、@classmethod
B、@class
C、@staticmethod
D、@static
Reference material 【 】
2、【 Judgment questions 】 If you use an instance object of a class to call a class method , The first parameter in the class method points to the instance object .
A、 correct
B、 error
Reference material 【 】
4-15 In class tests
1、【 Single topic selection 】 It is known that A Class __slots__ Defined as “slots=(‘a1’,‘a2’)”,B Class does not __slots__ Definition ,B yes A Subclasses of , be B The properties that the class can dynamically extend include ( ).
A、a1
B、a2
C、a1 and a2
D、 Any attribute
Reference material 【 】
4-16 In class tests
1、【 Single topic selection 】 by A Class t Property defines a method to get the value of the property ( namely getter), You should use ( ) Decorator .
A、@property
B、@t.getter
C、@property.getter
D、t.property.getter
Reference material 【 】
2、【 Judgment questions 】 If an attribute has only the value used to get the attribute getter Method , There is no... For setting the property value setter Method , Then the attribute is a read-only attribute .
A、 correct
B、 error
Reference material 【 】
Chapter IV procedure blank filling and procedure error correction
Chapter four Programming practice ( The first 2 Take turns to supplement )
Chapter 4 unit test
1、【 Single topic selection 】 Class ( ) Which operations can be supported by a corresponding class .
A、 attribute
B、 Method
C、 data
D、 object
Reference material 【 】
2、【 Single topic selection 】 by A Class t Property defines a method to get the value of the property ( namely getter), You should use ( ) Decorator .
A、@property
B、@t.getter
C、@property.getter
D、t.property.getter
Reference material 【 】
3、【 Single topic selection 】 The first formal parameter of a class method corresponds to ( ).
A、 class
B、 object
C、 The first argument
D、 The second argument
Reference material 【 】
4、【 Single topic selection 】 Determine whether a class is a subclass of another class , Built in functions should be used ( ).
A、isinstance
B、issubclass
C、type
D、isclass
Reference material 【 】
5、【 Single topic selection 】 stay A Class ,“super()” Equivalent to ( ).
A、super(A)
B、super(A,self)
C、super(self)
D、super
Reference material 【 】
6、【 Single topic selection 】 In the case of executing the same code , The system will call the methods in the corresponding class according to the class to which the object actually belongs , This feature is class ( ).
A、 encapsulation
B、 inheritance
C、 polymorphism
D、 Self adaptability
Reference material 【 】
7、【 Single topic selection 】 In the following options , The right description is ( ).
A、 The parent class inherits all the properties and methods defined in the child class , You can also add new properties and methods to the parent class
B、 The parent class inherits all the properties and methods defined in the child class , It is not allowed to add new properties and methods in the parent class
C、 Subclasses inherit all properties and methods defined in the parent class , You can also add new properties and methods to subclasses
D、 Subclasses inherit all properties and methods defined in the parent class , Adding new properties and methods in subclasses is not allowed
Reference material 【 】
8、【 Single topic selection 】 It is known that stu1 and stu2 yes Student Two objects of class , execute “stu1stu2” Will automatically execute Student Class ( ) Method .
A、gt
B、ge
C、lt
D、le
Reference material 【 】
9、【 Single topic selection 】 The method name of the destructor method is ( ).
A、destruct
B、term
C、del
D、end
Reference material 【 】
10、【 Single topic selection 】 Known through “stu=Student(‘1810101’,‘ Li Xiaoming ’)” You can create a Student Class object and assign it to stu, The number of formal parameters of the construction method executed when creating the object ( Without considering the indefinite length parameter ) by ( ).
A、1
B、2
C、3
D、4
Reference material 【 】
11、【 Single topic selection 】 We use the object name to call a common method in the class , Then the common method has at least ( ) Parameters .
A、0
B、1
C、2
D、3
Reference material 【 】
12、【 Single topic selection 】 It is known that Student Class is an empty class , Through “Student.name=‘unknown’” Statement can be added through ( ) visit .
A、 Class name or object name
B、 Class name only
C、 Only object names
D、 cannot access
Reference material 【 】
13、【 Multiple choice 】 Known in A Class defines the method fa, stay B Class defines the property b, stay C Class defines the method fc And attribute c,A yes B Parent class of ,B yes C Parent class of , be B The members in the class include ( ).
A、fa
B、b
C、fc
D、c
Reference material 【 】
14、【 Multiple choice 】 In the following options , The right description is ( ).
A、 There can only be one subclass in an inheritance relationship
B、 There can only be one parent class in an inheritance relationship
C、 A class may be a subclass in an inheritance relationship 、 In another inheritance relationship is the parent class
D、 A class may be a subclass in multiple inheritance relationships
Reference material 【 】
15、【 Multiple choice 】 In the following options , The right description is ( ).
A、 If a class property name starts with two underscores , Then this kind of attribute is private
B、 Private properties in a class can only be accessed within the class
C、 Private properties in a class can be accessed outside the class , But you can't directly use private attribute names
D、 Methods in a class cannot have default parameter values
Reference material 【 】
16、【 Multiple choice 】 In the following options , The right description is ( ).
A、 You can create a new class based on an existing class
B、 When defining a class, you must define all the properties and methods of the class
C、 After defining a class, you can also dynamically add properties and methods to it
D、 You can create new classes based on multiple existing classes
Reference material 【 】
17、【 Judgment questions 】 If a property has only the... Used to set the value of the property setter Method , There is no way to get the attribute value getter Method , Then the attribute is a write only attribute .
A、 correct
B、 error
Reference material 【 】
18、【 Judgment questions 】 It is known that B yes A Parent class of ,b yes B Class object , be “Atype(b)” The return result is True.
A、 correct
B、 error
Reference material 【 】
19、【 Judgment questions 】 Using the parent class object that you get, you can call the parent class method that is overridden in the subclass. .
A、 correct
B、 error
Reference material 【 】
20、【 Judgment questions 】 Method rewriting means that a subclass can redefine the methods inherited from the parent class , Thus, the subclass object can behave differently from the parent object .
A、 correct
B、 error
Reference material 【 】
21、【 Judgment questions 】 If a subclass has two or more parents , Then this inheritance relationship is called multiple inheritance .
A、 correct
B、 error
Reference material 【 】
5-01 In class tests
1、【 Judgment questions 】 For immutable types of objects a, Can pass “a=b” modify a Value .
A、 correct
B、 error
Reference material 【 】
2、【 Judgment questions 】 For objects of variable type a, adopt “a=b” You can modify a Value , But before and after assignment a The corresponding memory address may change .
A、 correct
B、 error
Reference material 【 】
5-02 In class tests
1、【 Single topic selection 】 It is known that “a=list((1,2))+list((2,3))”, be a The value of is ( ).
A、[1,2,3]
B、[1,2,2,3]
C、(1,2,3)
D、(1,2,2,3)
Reference material 【 】
2、【 Judgment questions 】list The result of the function must be a list .
A、 correct
B、 error
Reference material 【 】
5-03 In class tests
1、【 Single topic selection 】 It is known that “a=[1,2,3]” And “b=a”, execute “a[1]=10” after ,b The value of is ( ).
A、[10,2,3]
B、[1,10,3]
C、[1,2,10]
D、[1,2,3]
Reference material 【 】
2、【 Single topic selection 】 It is known that “a=[1,2,3]” And “b=a[:]”, execute “a[1]=10” after ,b The value of is ( ).
A、[10,2,3]
B、[1,10,3]
C、[1,2,10]
D、[1,2,3]
Reference material 【 】
5-04 In class tests
1、【 Single topic selection 】 From the list ( ) Method can find the position of the first matching list element according to the specified value .
A、index
B、find
C、search
D、at
Reference material 【 】
2、【 Judgment questions 】 It is known that “ls=[0,1,2,3,4,5,6,7,8,9]”, be “del ls[7:9]” And “ls[7:9]=[]” Got ls The elements in are the same .
A、 correct
B、 error
Reference material 【 】
5-05 In class tests
1、【 Single topic selection 】 Calculation list ls The number of elements in should use ( ).
A、ls.count()
B、count(ls)
C、ls.len()
D、len(ls)
Reference material 【 】
2、【 Judgment questions 】 adopt “ls.max()” You can get a list ls The value of the largest element in .
A、 correct
B、 error
Reference material 【 】
5-06 In class tests
1、【 Single topic selection 】 It is known that “ls=[1,3,2,5]”, execute “ls.sort()” after ls The value of is ( ).
A、[1,3,2,5]
B、[1,2,3,5]
C、[5,3,2,1]
D、[5,2,3,1]
Reference material 【 】
2、【 Judgment questions 】 List sort Methodical key The function received by the parameter must have a return value .
A、 correct
B、 error
Reference material 【 】
5-07 In class tests
1、【 Single topic selection 】 It is known that “a=tuple([1,2])+tuple([2,3])”, be a The value of is ( ).
A、[1,2,3]
B、[1,2,2,3]
C、(1,2,3)
D、(1,2,2,3)
Reference material 【 】
2、【 Judgment questions 】 adopt “max(t)” You can get tuples t The value of the largest element in .
A、 correct
B、 error
Reference material 【 】
5-08 In class tests
1、【 Single topic selection 】 Use a collection of update Method , The argument passed in must be ( ).
A、 Tuples
B、 list
C、 Hashable object
D、 Iteratable object
Reference material 【 】
2、【 Judgment questions 】 It is known that s={1,20,25}, Through “s.add([2,3])” Can be directed to s Add a new list type element .
A、 correct
B、 error
Reference material 【 】
5-09 In class tests
1、【 Single topic selection 】 If you want to calculate the intersection of two sets , Should use... In the set ( ) Method .
A、intersection
B、union
C、difference
D、symmetric_difference
Reference material 【 】
2、【 Judgment questions 】 It is known that s1 and s2 It's two sets , be “s1.issubset(s2)” And “s2.issuperset(s1)” The return result must be the same .
A、 correct
B、 error
Reference material 【 】
5-10 In class tests
1、【 Single topic selection 】 It is known that “d1={‘age’:19}”, execute “d1.fromkeys([‘sno’,‘name’])” after ,d1 The number of elements in is ( ).
A、0
B、1
C、2
D、3
Reference material 【 】
2、【 Single topic selection 】 It is known that “d1={‘age’:19}”, execute “d2=d1.fromkeys([‘sno’,‘name’])” after ,d2 The number of elements in is ( ).
A、0
B、1
C、2
D、3
Reference material 【 】
5-11 In class tests
1、【 Single topic selection 】 Use... In the dictionary ( ) Method can insert multiple elements at once .
A、add
B、update
C、push
D、insert
Reference material 【 】
2、【 Judgment questions 】 Known to perform “d=dict(sno=‘1810100’, name=‘ Li Xiaoming ’, age=19)”, execute “r=del d[‘age’]” after ,r The value of is 19.
A、 correct
B、 error
Reference material 【 】
5-12 In class tests
1、【 Single topic selection 】 It is known that “a=dict(x=1,y=2)” And “b=a”, execute “a[‘y’]=10” after , be print(b) The output of is ( ).
A、{x=1,y=10}
B、{x=1,y=2}
C、{‘x’:1,‘y’:10}
D、{‘x’:1,‘y’:2}
Reference material 【 】
2、【 Judgment questions 】 If the dictionary a Contains elements of variable types , I'm using a to b assignment , You should use copy Modular deepcopy function , So that a and b The value of each element in is completely independent .
A、 correct
B、 error
Reference material 【 】
5-13 In class tests
1、【 Single topic selection 】 It is known that “d=dict(x=1,y=2)”, be d.get(‘z’) The result is ( ).
A、None
B、default
C、null
D、 Report errors
Reference material 【 】
2、【 Judgment questions 】 It is known that d1 and d2 Are two dictionary objects , Directly “dMerge=dict(d1,d2)” And execute first “dMerge=d1.copy()”、 Re execution “dMerge.update(d2)” The effect is exactly the same .
A、 correct
B、 error
Reference material 【 】
5-14 In class tests
1、【 Single topic selection 】 It is known that “d=dict(x=1,y=2)”, execute “d.clear()” after ,“len(d)” The result is ( ).
A、0
B、1
C、2
D、 Report errors
Reference material 【 】
2、【 Judgment questions 】 adopt “d.keys()” Can be obtained from the dictionary d An object consisting of all the keys in the .
A、 correct
B、 error
Reference material 【 】
5-15 In class tests
1、【 Single topic selection 】 The operation of taking some elements from a sequence object to form a new sequence object is called ( ).
A、 choice
B、 section
C、 Subsequence
D、 Projection
Reference material 【 】
2、【 Judgment questions 】 The return result of the list generation expression is a list .
A、 correct
B、 error
Reference material 【 】
5-16 In class tests
1、【 Single topic selection 】 The generator solves the possible problems of using lists to store data ( ) problem .
A、 Out of memory
B、 Slow access
C、 Element values cannot be repeated
D、 Element can be modified
Reference material 【 】
2、【 Judgment questions 】 With the help of yield Keyword can use functions to realize the functions of the generator .
A、 correct
B、 error
Reference material 【 】
5-17 In class tests
1、【 Judgment questions 】 utilize iter Function can get iterators from iteratable objects .
A、 correct
B、 error
Reference material 【 】
2、【 Judgment questions 】 Able to use next The objects that get the value of the next element are iterators .
A、 correct
B、 error
Reference material 【 】
Chapter 5 programming practice
Chapter 5 programming practice ( The first 2 Take turns to supplement )
Chapter V unit test
1、【 Single topic selection 】 It is known that “a=list(‘my’)+list(‘book’)”, be a The value of is ( ).
A、’[‘m’,‘y’,‘b’,‘o’,‘k’]
B、[‘m’,‘y’,‘b’,‘o’,‘o’,‘k’]
C、‘mybook’
D、‘mybok’
Reference material 【 】
2、【 Single topic selection 】 It is known that “a=[1,2,3]” And “b=a[:]”, execute “a[1]=10” after ,b The value of is ( ).
A、[10,2,3]
B、[1,10,3]
C、[1,2,10]
D、[1,2,3]
Reference material 【 】
3、【 Single topic selection 】 It is known that “a=[1,[2,3]]” And “b=a[:]”, execute “a[1]=10” after ,b The value of is ( ).
A、[1,10]
B、[1,[2,3]]
C、[1,[10,3]]
D、 Report errors
Reference material 【 】
4、【 Single topic selection 】 From the list ( ) Method can insert an element into the specified position of the list .
A、insert
B、append
C、add
D、push
Reference material 【 】
5、【 Single topic selection 】 Calculation list ls The number of elements in should use ( ).
A、ls.count()
B、count(ls)
C、ls.len()
D、len(ls)
Reference material 【 】
6、【 Single topic selection 】 It is known that “ls=[1,3,2,5]”, execute “ls.sort(reverse=True)” after ls The value of is ( ).
A、[1,3,2,5]
B、[1,2,3,5]
C、[5,3,2,1]
D、[5,2,3,1]
Reference material 【 】
7、【 Single topic selection 】 It is known that “a=tuple(‘my’)+tuple(‘book’)”, be a The value of is ( ).
A、’(‘m’,‘y’,‘b’,‘o’,‘k’)
B、(‘m’,‘y’,‘b’,‘o’,‘o’,‘k’)
C、‘mybook’
D、‘mybok’
Reference material 【 】
8、【 Single topic selection 】 Use a collection of add Method , The argument passed in must be ( ).
A、 Tuples
B、 list
C、 Hashable object
D、 Iteratable object
Reference material 【 】
9、【 Single topic selection 】 If you want to calculate the symmetric difference set of two sets , Should use... In the set ( ) Method .
A、intersection
B、union
C、difference
D、symmetric_difference
Reference material 【 】
10、【 Single topic selection 】 It is known that “d1={‘age’:19}”, execute “d2=d1.fromkeys([‘sno’,‘name’])” after ,d1 The number of elements in is ( ).
A、0
B、1
C、2
D、3
Reference material 【 】
11、【 Single topic selection 】 Use... In the dictionary ( ) Method can delete the element of the specified key .
A、del
B、delete
C、pop
D、remove
Reference material 【 】
12、【 Single topic selection 】 It is known that “a=dict(x=1,y=2)” And “b=a.copy()”, execute “a[‘y’]=10” after , be print(b) The output of is ( ).
A、{x=1,y=10}
B、{x=1,y=2}
C、{‘x’:1,‘y’:10}
D、{‘x’:1,‘y’:2}
Reference material 【 】
13、【 Single topic selection 】 It is known that “t=tuple(range(0,10))”, be print(t[-1:3:-2]) The result is ( ).
A、[9,7,5]
B、(9,7,5)
C、[9,7,5,3]
D、(9,7,5,3)
Reference material 【 】
14、【 Multiple choice 】 Use a collection of add Method , The argument passed in can be ( ).
A、 Numbers
B、 Tuples
C、 list
D、 character string
Reference material 【 】
15、【 Multiple choice 】 It is known that s1 and s2 It's two sets , Then the return result must be True Options include ( ).
A、s1.union(s2).issubset(s1)
B、s1.union(s2).issuperset(s1)
C、s1.difference(s2).issubset(s1)
D、s1.difference(s2).issuperset(s1)
Reference material 【 】
16、【 Multiple choice 】 For a dictionary object d, If judgment is needed d Whether the key contained in the is ’x’ The elements of ( Include return True, Does not include return False), The statements you can use include ( ).
A、d.get(‘x’)!=None
B、d.get(‘x’)!=default
C、‘x’ in d
D、d.has(‘x’)
Reference material 【 】
17、【 Multiple choice 】 In the following options , The right description is ( ).
A、 All iterators are iteratable objects
B、 All iteratable objects are iterators
C、 adopt “isinstance(x,Iterator)” Can be judged x Is it an iterator
D、 If an iteratable object can pass through next The function keeps getting the value of the next element , Then it is an iterator
Reference material 【 】
18、【 Judgment questions 】 adopt “min(ls)” You can get a list ls The value of the smallest element in .
A、 correct
B、 error
Reference material 【 】
19、【 Judgment questions 】 It is known that “t=(True)”, be t It's a tuple .
A、 correct
B、 error
Reference material 【 】
20、【 Judgment questions 】 It is known that s={1,20,25}, Through “s.add((2,3))” Can be directed to s Add a new element of the tuple type .
A、 correct
B、 error
Reference material 【 】
21、【 Judgment questions 】 It is known that s1 and s2 It's two sets , execute “s1.union(s2)” after ,s1 The element in is the original s1 and s2 The union of elements in two sets .
A、 correct
B、 error
Reference material 【 】
22、【 Judgment questions 】 Able to use next The objects that get the value of the next element are iterators .
A、 correct
B、 error
Reference material 【 】
6-01 In class tests
1、【 Judgment questions 】 When using three quotation marks to create a string, it is allowed to write the string directly into multiple lines .
A、 correct
B、 error
Reference material 【 】
2、【 Judgment questions 】 The escape character... Is not allowed when creating a string with three quotation marks .
A、 correct
B、 error
Reference material 【 】
6-02 In class tests
1、【 Judgment questions 】 Use strcmp Function can compare strings .
A、 correct
B、 error
Reference material 【 】
6-03 In class tests
1、【 Single topic selection 】 It is known that “str='abcd’”, be “str.split(’’,2)” The return result is ( ).
A、[‘a’,’’,‘b’,‘c’,‘d’]
B、[‘a’,‘b’,‘c’,‘d’]
C、[‘a’,’’,'bcd’]
D、[‘a’,‘b’,'cd’]
Reference material 【 】
2、【 Single topic selection 】 It is known that “str=‘abcd’”, be “str.split(’’,2)” The return result is ( ).
A、[‘a’,‘b’,‘c’,‘d’]
B、[‘a’,‘b’,‘cd’]
C、[‘a’,'bc*d’]
D、 Report errors
Reference material 【 】
6-04 In class tests
1、【 Single topic selection 】 It is known that “str=‘Python#C++##Python’”, be “str.find(‘Python’)” The result is ( ).
A、0
B、12
C、-1
D、 Report errors
Reference material 【 】
2、【 Judgment questions 】 It is known that “str=‘abcdefabc’”, execute “str.replace(‘abc’,‘cba’)” after ,str The string saved in is ’cbadefcba’.
A、 correct
B、 error
Reference material 【 】
6-05 In class tests
1、【 Single topic selection 】 If you want to remove all spaces from the string , You can use string ( ) Method .
A、strip
B、lstrip
C、rstrip
D、replace
Reference material 【 】
2、【 Judgment questions 】 It is known that “str=‘Like’”, execute “str.upper()” after ,str The saved data is a string ’LIKE’.
A、 correct
B、 error
Reference material 【 】
6-07 In class tests
1、【 Single topic selection 】 It is known that n=31, be “print(’%X’%n)” The output result after execution is ( ).
A、31
B、1F
C、1f
D、37
Reference material 【 】
2、【 Judgment questions 】 Using string format Method to format a string , The replacement field needs to be enclosed in a pair of braces in the string .
A、 correct
B、 error
Reference material 【 】
6-08 In class tests
1、【 Single topic selection 】 And regular expressions “^ab[a-z]+c” The matching string is ( ).
A、abdec
B、abc
C、ab0c
D、cabc
Reference material 【 】
2、【 Single topic selection 】 And regular expressions “^ab[a-z]?c” The matching string is ( ).
A、abdec
B、abc
C、ab0c
D、cabc
Reference material 【 】
6-09 In class tests
1、【 Single topic selection 】 Use re.match Function for regular expression matching , If you want to ignore case , Then... Should be specified in the matching options ( ).
A、re.A
B、re.I
C、re.M
D、re.S
Reference material 【 】
2、【 Judgment questions 】 Use re.match Function for regular expression matching , If the specified matching options include re.MULTILINE, Then several characters at the beginning of each line will be matched .
A、 correct
B、 error
Reference material 【 】
6-10 In class tests
1、【 Judgment questions 】re.search(r’pyKaTeX parse error: Undefined control sequence: \npython at position 86: …h(r'^py','puppy\̲n̲p̲y̲t̲h̲o̲n̲',re.M) Back to a Ma…” It can be used with any “ab” start 、 With “c” The ending string matches .
A、 correct
B、 error
Reference material 【 】
20、【 Judgment questions 】re.match(r’pyKaTeX parse error: Undefined control sequence: \Python at position 2789: …】 10、【 Multiple choice 】 Known in D:\̲P̲y̲t̲h̲o̲n̲ There is a test.dat writing …’,‘puppy’) Back to a Match object .
A、 correct
B、 error
Reference material 【 】
71、【 Judgment questions 】 Regular expressions “\Aabc” And regular expressions “^abc” The same function , Are used to match to abc Starting string .
A、 correct
B、 error
Reference material 【 】
72、【 Judgment questions 】‘os.path.join(’.’,‘src’,‘tools’) And ’.{0}src{0}tools’.format(os.sep) The returned string is the same .
A、 correct
B、 error
Reference material 【 】
73、【 Judgment questions 】 If an exception cannot be by any except Clause capture , The program will throw the exception and stop .
A、 correct
B、 error
Reference material 【 】
74、【 Judgment questions 】 If one except Clause catches multiple exceptions , Then multiple exception names should be written as tuples .
A、 correct
B、 error
Reference material 【 】
75、【 Judgment questions 】 There are known statements “assert num==0”, Then when num The value of is 0 Will cause AssertionError abnormal .
A、 correct
B、 error
Reference material 【 】
Source code program developmen
Python3.9.0 for windows- Very
List of articles 1、 Create wor
原文轉載自「劉悅的技術博客」https://v3u.cn/a