Python Basics ===python Basics Quiz

Source: Internet
Author: User

1. What exactly is Python? You can compare it with other technologies in your answer.

Python is an interpreted language. Unlike the C language and C's derived languages, Python code does not need to be compiled before it can be run. Other explanatory languages include PHP and Ruby.

Python is a dynamic type language, meaning that you do not need to describe the type of a variable when declaring it.

Python is ideal for object-oriented programming (OOP) because it supports the definition of classes (class) by combining (composition) and Inheritance (inheritance).

There are no access specifiers in Python (access specifier, like public and private in C + +), so the design is based on "everyone is an adult."

In the Python language, a function is the first class of objects (first-class objects). This means that they can be assigned to a variable, and the function can either return the function type or accept the function as input. Class is also the first class of objects.

Python code is written fast, but runs slower than the compiled language. Fortunately, Python allows for the inclusion of extensions written in C language, so we can optimize the code to eliminate bottlenecks, which is usually achievable.

Python is very versatile-Web applications, automation, scientific modeling, big data applications, and more. It is also often used as a "glue language" to help other languages and components improve health.

2. What is PEP8?

PEP8 is a programming specification that contains suggestions on how to make your program more readable.

Its main contents include code orchestration, document orchestration, use of spaces, annotations, document description, naming conventions, coding suggestions, etc.

3. What are pickling and unpickling?

The pickle module reads any Python objects, converts them into strings, and then dumps them into a file using the Dump function-a process called pickling.

Instead, the process of extracting the original Python object from the stored string file is called Unpickling.

How is the 4.Python interpreted?

Python is an explanatory language, and its source code can be run directly. The Python interpreter converts the source code into an intermediate language, which is then translated into machine code for execution.

How does 5.Python manage memory?

Python's memory management is managed by the private heap space. All Python objects and data structures are in a private heap. The programmer does not have permission to access the heap, and only the interpreter can manipulate it.

Allocating memory for Python's heap space is done by Python's memory management module, whose core API provides some way to access the module for programmers to use.

Python has its own garbage collection system that reclaims and frees unused memory so that they can be used by other programs.

6. What tools are available to help debug or do static analysis?

Pychecker is a static analysis tool that not only reports errors in the source code, but also reports the type and complexity of the errors. Pylint is another tool for verifying that a module is meeting code standards.

7. What is a python adorner?

The Python adorner is a unique change in Python that makes it easier to modify a function.

8. What is the difference between an array and a tuple?

The difference between an array and a tuple: the contents of the array can be modified, and the tuple content is read-only. In addition, tuples can be hashed, for example, as a dictionary keyword.

9. How is the parameter passed by value and the reference pass implemented?

Everything in Python is a class, and all variables are references to an object. The referenced value is determined by the function and cannot be changed. But if an object can be modified, you can change the object.

10. What are dictionary derivation and list derivation?

They are a syntactic structure that makes it easy to create dictionaries and lists.

What data structures are available in 11.Python?

Python comes with data structures that are mutable and immutable. mutable: Arrays, sets, dictionaries, immutable: strings, tuples, numbers.

12. What is a Python namespace?

In Python, all names exist in one space, they exist and are manipulated in that space--that is, namespaces.

It's like a box, each variable name corresponds to an object. When a variable is queried, the corresponding object is found in the box.

What is a lambda in 13.Python?

This is an anonymous function that is often used in a single expression in your code.

14. Why does Lambda have no statements?

The reason that the anonymous function lambda does not have a statement is that it is used to construct a new function object and return it when the code is executed.

What is the pass in 15.Python?

Pass is a statement that will not be executed in Python. In complex statements, if a place needs to be temporarily left white, it is often used for placeholders.

What is a walker in 16.Python?

A walker is used to traverse a set of elements, such as a container such as a list.

What is the unittest in 17.Python?

In Python, UnitTest is the unit test framework in Python. It has the ability to support shared builds, automated testing, pausing code in tests, iterating over different tests, and so on.

18. What is slicing in python?

Slicing is a syntax for an excerpt of a paragraph in an ordered object type (array, tuple, string).

19. What is a constructor in python?

Generators are a mechanism for implementing iterators. The implementation of this function relies on the yield expression, except that it is not the same as a normal function.

What is the docstring in 20.Python?

The python Chinese file string is called DocString, and its role in Python is to generate documents for functions, modules, and class annotations.

21. How do I copy an object in Python?

If you want to copy an object in Python, most of the time you can use Copy.copy () or copy.deepcopy (). But not all objects can be copied.

What is a negative index in 22.Python?

The sequence index in Python can be either positive or negative. If it is a positive index, 0 is the first index in the sequence, and 1 is the second index. If it is a negative index, (-1) is the last index and (-2) is the second-lowest index.

23. How do I convert a number to a string?

You can use the Self-function str () to convert a number to a string. If you want octal or hexadecimal numbers, you can use the OCT () or Hex ().

What is the difference between 24.Xrange and range?

Xrange is used to return an Xrange object, and range is used to return an array. No matter how big the range, Xrange uses the same memory.

What are the modules and packages in 25.Python?

In Python, a module is a way to build a program. Each Python code file is a module and can refer to other modules, such as objects and properties.

A folder that contains a lot of Python code is a package. A package can contain modules and sub-folders.

Python Basics ===python Basics Quiz (GO)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.