Python engineer must-see interview questions and answers

 

1) What is Python? Using Python What are the benefits?

Python is a programming language, contains objects, modules, threads, exceptions, and automatic memory management. Python advantage lies in its ease of use, portability, scalability, built-in data structures, and it is an open source.

2) What is PEP 8?

PEP 8 is a coding convention, a set of recommendations on how to write Python code more readable.

3) What is pickling  and unpickling ?

Pickle module accepts any Python object and convert it to a string representation, and using the function to dump dump of a process called pickling. Python retrieve the original object from the string representation of the stored procedure called unpickling.

4) how to interpret Python? For more learning materials, with the big cow guide the exchange Q group 519,970,686

Python language is an interpreted language. Python is running directly from the source code. It programmers write source code into an intermediate language, again converted into machine language that must be performed.

5) How to manage memory in Python?

  • Python heap memory space managed by the private Python. All Python objects and data structures are located in private heap. Programmers do not have access to this private heap, the interpreter is responsible for handling this private heap.
  • Python Python object heap space allocation done by the Python memory manager. The core API provides tools programmers to write code.
  • Python also has a built-in garbage collection, which can recycle all unused memory and frees up memory and makes it available for heap space.

6) What tools can help you find an error or perform static analysis?

PyChecker is a static analysis tool that can detect Python source code for errors, warnings and errors of style and complexity. Pylint is another tool coding standards compliance verification module.

7) What is the Python decorator?

Python decorator is a specific change that we made in the Python syntax, you can easily change the function.

8) list and tuple What is the difference?

The difference between the list of lists and tuples that is variable rather than tuples. Tuple hash, for example, may be used as a key dictionary.

How 9) parameters are passed by value or by reference?

All content in Python is an object, all variables are contained object. According to the reference value function; therefore, you can not change the value of the reference. However, if the object is a variable, you can change them.

10) What Dict List and understanding?

They are grammatical structure, you can easily create a Dictionary or List based on existing iterable.

11) What is the built-in type python offer?

 

And a variable type immutable type Pythons built to construct Mutable

  • List
  • Collection
  • dictionary

Built-in type immutable

  • String
  • Tuple
  • digital

12) What is the name space in Python?

In Python, introducing each name has a place exists, and can be linked. This is known as a namespace. It is like a box, where the variable name is mapped to the object placement. Whenever the variable search, the search box for the corresponding object.

13) What in Python lambda that?

It is a single anonymous function expression, commonly used as inline functions.

14) Why is the form in python lambda no statement?

lambda form in python no statement, because it is used to create new function objects and then return them at runtime.

15) What is the Python transfer?

By means no operation of Python statements, or in other words, it is a placeholder for the compound statement, which should be left blank, do not write anything in there.

16) in Python What is an iterator?

In Python, iterator to iterate a set of elements, such as a list or the like containers.

17) What is the Python unit test?

Python unit testing framework is called unittest. It supports sharing settings, automated testing, test closing code, to set the test polymerization and the like.

18) What is sliced ​​in Python?

Sequence type selected from a list of items (e.g., lists, tuples, string, etc.) is a mechanism called slices.

19) What is the Python generators are?

Implemented method iterator known as a generator. This is a normal function, except that it generates an expression in the function.

20) What is the Python docstring that? Python learning, communication, enhance the Q group 519 970 686

 

Python string called the docstring of the document, which is a method Python functions, modules and classes of records.

21) How to copy objects in Python?

To copy an object in Python, try copy.copy () or copy.deepcopy () to handle the general case. You can not copy all of the objects, but most objects are true.

What 22) Python indexes are in negative?

Python sequence can be positive and negative numbers in the index. For positive index, the first index is 0, 1 is the second index, and so on. For negative indices, (--1) is the last index, (- 2) is the reciprocal of the second index, and so on.

23) How to convert a number to a string?

To convert a number to a string, use the built-in function str (). If you need octal or hexadecimal representation, use the built-in functions oct () or hex ().

24) Xrange and scope What is the difference?

Xrange return xrange object, and range returns a list, and use the same memory, regardless of the size range is.

25) What Python modules and packages are?

In Python, a program module is constructed. Python is a program file for each module, which import other modules, such as objects and attributes.

Python file folder is a program module package. A package can contain modules or sub-folders.

26) What are the rules mentioned in Python local and global variables are?

Local variables : If at any point a variable function in the body is assigned a new value, it is assumed to be local.

Global variables : Only variable references within the function is implicit global variables.

27) How to share a global variable across modules?

To share a global variable across modules in a single program, create a special module. Import configuration module all modules of the application. The module will be available as a global variable across modules.

28) explains how to create Python scripts on Unix?

To make a Python script executable on Unix, you need to do two things,

 

  • Mode script file must be executable
  • The first line must start with # (#! / Usr / local / bin / python)

29) explains how to delete a file in Python?

Use the command os.remove (filename) or os.unlink (filename)

30) explains how to generate random numbers in Python?

To generate random numbers in Python, you will need to import the command

Introduced randomly

random.random()

This returns a random float within the range [0, 1]

31) explains how to use access module written in Python from Ç?

Modules written in Python that you can access by using the following method Ç,

Module = = PyImport_ImportModule(“<modulename>”);

32) referred to the use in the // operator's Python?

It is a Floor Divisionoperator, for dividing the two operands, the result is the quotient digits before the decimal point show only. For example, 5 = 2 // 10 // 5.0 = 10.0 and 2.0.

33) mentions the use of five major benefits in Python? Python learning materials to share, Daniel answers to technical bottlenecks Q group 519,970,686

  • Python contains a large standard library for most of the Internet platform, such as e-mail, HTML and so on.
  • Python is no explicit memory management, because the interpreter itself will be allocated to the new memory variable and release them automatically
  • The use of square brackets, it is easy to read
  • Easy to learn for beginners
  • Has a built-in data types can save programming time and effort in order to declare variables

34) mentioned  in the Python using the split function ?

In using the Python splitting function defined using resolving string delimiter shorter string. It gives a list of all the words that exist in the string.

35) What is the explanation  Flask and its benefits ?

Flask is a Web-based micro framework .Werkzeug "Werkzeug, Jinja 2 and good intentions" BSD licensed Python and jingja its two dependencies.

Bottles are part of micro-frame. This means that it has almost no external library dependencies. It makes the frame becomes light, while almost no updated dependence and fewer security bugs.

36) Django mentioned, Pyramid and  Flask What is the difference between?

 Flask is a "micro-frame", mainly used in small applications a simpler requirements. In  Flask , you must use an external library .Flask ready to use.

Pyramid was built for larger applications. It provides flexibility and allows developers to use the right tool for their projects. Developers can select the database, URL structure, template styles. Pyramid is important.

Like Pyramid , like, Django can also be used for larger applications. It includes an ORM.

 

37) What is mentioned  Flask- what WTF and their characteristics are?

Flask-WTF offers simple integration with WTForms of. Features include Flask WTF

  • Integration with wtforms
  • Use Form CSRF token protection
  • Global CSRF protection
  • International integration
  • Code Support
  • Upload file suitable for upload Flask

38) explain  Flask What is the common method of script work?

 Flask common method script work is

  • It should be a path to your import application
  • Python path or file

 

39) explains how the  Flask access session?

Session basically allows you to remember information request from one request to another. In  Flask , it uses the signature cookie, so that users can view and modify the contents of the session. If only the key Flask.secret_key, the user can modify the session.

40) bottle is a MVC model, and if so, give an example shows the MVC pattern for your application?

Basically,  the Flask is a simple frame, the frame behaves the same MVC. So MVC is ideal for  the Flask , MVC model we will consider the following example

Here Insert Picture Description

Flask support database-driven applications (RDBS). Such systems need to create a model that requires delivery of documents to shema.sql sqlite3 command. Therefore, you need to install sqlite3 command to create or start a database with Flask.

Flask three ways allows the request database

  • before_request (): call request and before they pass no parameters
  • after_request (): invoke them and pass the request to send the response to the client
  • teardown_request (): call them when an exception is thrown, and does not guarantee a response. Call them after building response. They are not allowed to modify the request and ignore their values.

42) Do you have multiple servers running the Python Memcache, memcacher one server fails, it has your data, it will try to obtain critical data from the failed server?

Data server failure will not be deleted, but the provisions of an automatic failure, you can configure multiple nodes. Failover can be triggered during any type of socket or Memcached server level errors, rather than the triggering period (such as adding existing key, etc.) in a normal client error.

43) explains how to minimize the development of Python Memcached server outage?

  • When an instance fails, the failure of which some examples, when the client makes a request to reload the lost data, this will lead to greater database server load. To avoid this, if your code has been written to minimize the cache tag, it will have minimal impact
  • Another approach is to use Memcached instances the lost machine IP address of the machine in the new call up
  • Code is another option to minimize server outages, because it allows you the freedom to work with minimal changes Memcached server list
  • Set the timeout value is another option some Memcached Memcached client server interruption to achieve. When the Memcached server fails, the client will continue to attempt to send the request until the timeout limit

44) Explain what is Dogpile Web site effects? How can you prevent this effect?

When the cache expires, Dogpile Web site effect is called an event, and the site has been hit by multiple client requests simultaneously issued. Use of semaphores locks prevent this effect. In this system, when the value of the expiration of the first process to acquire the lock and start creating new value.

45) does not explain how to use the Python Memcached project?

  • Memcached is a common mistake to use it as a data storage instead of caching
  • Do not use as a sole source of information needed to run the application's Memcached. Data should always be provided by other sources
  • Memcached is only a memory key or value, can not be performed on the data or iterative queries to extract information content
  • Memcached does not provide any form of security encryption or authentication aspects

Guess you like

Origin blog.csdn.net/weixin_41752475/article/details/92377077