Python basic self-test answers and basic knowledge combing

Python basic self-test answers and basic knowledge combing

1. The function body of lambda expression in Python can be a single statement, so the answer is C.
For example: >>>g = lambda x: 2*x+1

g(3)
7

2. Variables in Python do not need to be declared in advance, but they need to be created and assigned. Otherwise, how do you use them? The answer is B.
The supplementary variable name can include letters, numbers, and underscores, but the variable cannot start with a number.

3. The Python language divides sentence blocks by indentation alignment. Choose A.
4. Strings in Python can appear in single quotes, double quotes, and triple quotes, but they need to appear in pairs, otherwise an error will occur. Choose D.
5. The concept of iterator in Python, the container that provides iterative methods is called iterator. Usually the iterators contacted are sequences (lists, tuples, strings) and dictionaries are all iterators, and iterators can only move forward . Choose D for the answer.
6. Answer B. do while is not a python statement.
7. Answer D.
8. Answer A. For example

for i in range(1,10,2):

  print(i)

1
3
5
7
9
So its return value is an iterable object.
Choose B. The .py extension is the Python source code file, the .pyc extension is the Python compiled file, the .pyo is compiled and optimized, and .pyd is not compiled from Python.
Choose D. Variable objects in Python include: dictionaries, lists, and collections.

Here is the basic knowledge of Python entry
Python basic self-test answers and basic knowledge combing

Python basic self-test answers and basic knowledge combing

Python basic self-test answers and basic knowledge combing

Guess you like

Origin blog.51cto.com/14993422/2548652