python final exam test questions ape small circle of python (a)

Fast approaching the final exam, little friends are anxious not started yet? Hanging branches how to do? If you are lucky to see the small series of articles, you are smiling now, Xiao Bian summed up: General python final exam to test the contents of their favorite teachers, better than some good-looking ah, strive to achieve python hanging branches; there are summer immediately to a small partner who can spare the occasion to see a small ape circle video , to find a job after mat mat foundation, it is also very good.
First, the choice

1, the known x = [1,2] and y = [3,4], then x + y is equal to what is (C)

A,. 3 B, C. 7, [1,2,3,4] D, [. 4 , 6]

2, the following methods os.path module, which is used to determine whether there is a specified path? (A)

A, EXISTS () B, exist () C, getSize () D, the isfile ()

3, the following options are not written in Python method for file operations is (D)

A、 writelines B、write C、rite 和 seek D、writetext

4, a description of the algorithm, the following error is (B)


A, the algorithm refers to the accurate and complete description of the problem-solving program


Complexity of B, including the complexity of the algorithm complexity and time data


C, the algorithm is feasible, uncertainty, there are the basic characteristics of the poor


D, the basic elements of the structure includes a control algorithm arithmetic operations and algorithms and data objects
explanation: algorithm complexity algorithm refers to resources after the preparation into an executable program, run time needed resources include time and memory resources.

5 ,. about Python lambda functions, the following options are described in the error (B)


A, lambda function returns the name of the function as a function of the result


B, f = lambda x, y: x + y After execution, the type of a digital type f


Simple C, lambda is used to define a function that can be represented in a row


D, you can use an ordering principle lambda function definition list

6, the role of basic Python built-in function eval (x) is (B)

A, converted to floating point x

B, removing the outermost string x marks, Python expression evaluation as to return its value

C, the string x is calculated as a value statement Python

D, and the integer x to a hexadecimal string

Second, fill in the blank

1, represents in Python ____ empty type. (None)

2, see the Python built-in function of the variable type is ______. (Type ())

3, list (map (str, [1, 2, 3])) ___________ execution result. ([ '1', '2', '3'])

4, the square root function calculation math Python standard library is used in ____. (Sqrt)

5, assume that the list a = [ 'name', 'age', 'sex'] and b = [ 'Dong', 38, 'Male'], use one of these two statements list content into the dictionary, and a list of elements is a "key" to the list of elements b "value", this statement can be written as ___________. (C = dict (zip (a, b)))

Third, the short answer questions

1, a simple explanation Python-based automatic memory management values?

---- Python uses is based on the worth of memory management in Python can be assigned to different variables to the same value that only one in memory, multiple variables point to the same memory address; Python has automatic memory management functions automatically track all values ​​in memory, there is no value for any variable points, Python automatically deleted.

2, exceptions and error what is the difference?

---- refers to the abnormal behavior is due to an error during program execution taken outside the normal flow of control. Strictly speaking, grammatical errors, and logic errors are not unusual, but some grammatical errors often lead to abnormal, for example due to the capitalization misspelling access object does not exist, or trying to access the file does not exist, and so on.

3, use their own algorithms, the following ascending order merging two List, and remove duplicate elements:

list1 = [2, 3, 7, 4, 9, 5, 6,18]

list2 = [5, 6, 10, 17, 3, 2,1]

---- first converted into a weight set to automatic, converted to a list
List1 = [2,. 3,. 7,. 4,. 9,. 5, 6,18]
List2 = [. 5,. 6, 10,. 17,. 3, 2, . 1]
list3 List = (SET (List1 + List2))

4, find results

1 def num():
2 
3     return [lambda x: i*x for i in range(4)]
4 
5 print([m(2) for m in num()])

Answer: [6, 6, 6, 6]

5, how to generate a random number?

import random
def rdm(n):
lis = []
for i in range(n):
n = random.randint(1,9)
lis.append(str(n))
s = ''.join(lis)
return int(s)

This set of questions on here, the students how to do ah, if there is no pressure, it is estimated that you have learned this semester with a wide python also, if a little more difficult, it would have to take a closer look, because this topic very basic, Behold did not learn to understand, take a look at the contents of that part of its own review does not go in, can also be small ape circle to see their own weaknesses to re-listen to lectures in preparation for the final exam, I hope we will test the Mongolia's all right, come on it!

Guess you like

Origin www.cnblogs.com/xiaoyuanquan/p/10949196.html