The interview questions for Python engineers are related to the basic Python syntax.

Source: Internet
Author: User

The interview questions for Python engineers are related to the basic Python syntax.

I hope that this article will help you smoothly pass the Python interview, and you will be welcomed to read another article on Python Web.

1. What is the role of the pass statement in Python?
The pass statement does not do anything. Generally, it acts as a placeholder or creates a placeholder program. The pass statement does not perform any operations.

2. How does Python convert data types?
Python provides built-in functions that convert variables or values from one type to another. For example, the int function can convert a numeric string in a mathematical format to an integer. Otherwise, an error message is returned.

3. How does Python perform memory management?
Python references a memory pool mechanism, namely, the Pymalloc mechanism (malloc: n. memory Allocation), to manage the application and release of small memory blocks.

4. What are the differences between the items () method and the iteritems () method of dict?
The items method returns all dictionaries in a list, where items have no special order when they are returned;
The iteritems method has a similar effect, but returns an iterator object.
5. What is a lambda function? What are its advantages?
Lambda expressions mentioned in programming are usually used when a function is needed but you do not want to bother naming a function, that is, anonymous functions.
Python allows you to define a single-row small function. The lambda function is defined as follows: labmda parameter: The expression lambda function returns the value of the expression by default. You can also assign a value to a variable. Lambda functions can accept any parameter, including optional parameters, but the expression has only one.
6. Why are OS and sys modules different and common module methods listed?
Official explanation:
OS: This module provides a portable way of usingoperating system dependent functionality.
Provides a convenient way to use operating system functions.
Sys: This module provides access to some variablesused or maintained by the interpreter and to functions that interact stronglywith the interpreter.
Translation: provides access to variables used or maintained by the interpreter and functions used in interaction with the interpreter.
Common OS Methods

OS. remove () delete file OS. rename () rename the file OS. walk () generates all file names under the directory tree OS. chdir () changes the directory OS. mkdir/makedirs create directory/multi-level directory OS. rmdir/removedirs Delete directory/multi-level directory OS. listdir () lists the file OS in the specified directory. getcwd () gets the current working directory OS. chmod () changes the directory permission OS. path. basename () removes the directory path and returns the file name OS. path. dirname () removes the file name and returns the directory path OS. path. join () combines the separated parts into a path name OS. path. split () returns the (dirname (), basename () tuples OS. path. splitext () (returns filename, extension) tuples OS. path. getatime \ ctime \ mtime returns the last access, creation, and modification time OS respectively. path. getsize () returns the file size OS. path. exists () Whether OS exists. path. whether isabs () is an absolute path OS. path. whether isdir () is a directory OS. path. whether isfile () is a file

Common sys Methods

Sys. argv command line parameter List. The first element is the program path sys. modules. keys () returns the list of all imported modules sys. exc_info () obtains the exception classes currently being processed, including exc_type, exc_value, and exc_traceback. exit (n) exit the program. exit (0) sys when the program Exits normally. hexversion gets the version value of the Python interpreter. The hexadecimal format is 0x020403F0 sys. obtain the version information of the Python interpreter sys. the maximum Int value of maxint sys. the maximum Unicode value of maxunicode is sys. modules returns the module field imported by the system. The key is the module name and the value is the module sys. path: return the search path of the module. during initialization, use the value of the PYTHONPATH environment variable sys. platform returns the name of the operating system platform sys. stdout standard output sys. stdin standard input sys. stderr error output sys. exc_clear () is used to clear the current or recent error message of the current thread sys.exe c_prefix and return to the location where the python file on the platform is installed. sys. byteorder refers to the indicator of the local byte rule. The value of the big-endian platform is 'Big ', and the value of the little-endian Platform Is 'Little 'sys. copyright records python copyright related things sys. API version sys of C of api_version interpreter. version_info sys. argv command line parameter List. The first element is the program path sys. modules. keys () returns the list of all imported modules sys. exc_info () obtains the exception classes currently being processed, including exc_type, exc_value, and exc_traceback. exit (n) exit the program. exit (0) sys when the program Exits normally. hexversion gets the version value of the Python interpreter. The hexadecimal format is 0x020403F0 sys. obtain the version information of the Python interpreter sys. the maximum Int value of maxint sys. the maximum Unicode value of maxunicode is sys. modules returns the module field imported by the system. The key is the module name and the value is the module sys. path: return the search path of the module. during initialization, use the value of the PYTHONPATH environment variable sys. platform returns the name of the operating system platform sys. stdout standard output sys. stdin standard input sys. stderr error output sys. exc_clear () is used to clear the current or recent error message of the current thread sys.exe c_prefix and return to the location where the python file on the platform is installed. sys. byteorder refers to the indicator of the local byte rule. The value of the big-endian platform is 'Big ', and the value of the little-endian Platform Is 'Little 'sys. copyright records python copyright related things sys. API version sys of C of api_version interpreter. version_info

7. How to copy an object in Python? What is the difference between deepcopy and copy?
Copy only copies the object itself, but does not copy other objects referenced in the object.
In addition to the object itself, deepcopy also copies other objects referenced in the object.
8. What is the difference between OS. path and sys. path?
OS. path is a module that contains various functions that process long file names (path names.
Sys. path is a list composed of directory names. Python searches for extension modules (Python source module, compilation module, or binary extension ). when Python is started, the list is initialized Based on built-in rules, the content of the PYTHONPATH environment variable, and the Registry (Windows System.
9. What are the differences between the match and search methods in the re module?
The match () function only checks whether the RE matches the string at the beginning, while the search () function scans the entire string.
10. How to implement and use a simple generator?
The main difference between a generator and a function is the return avalue function. the yield a value generator simultaneously marks or remembers the point of the yield to resume execution from the mark point during the next call. Yield converts a function into a generator, and the generator returns the iterator in turn.

Only these 10 are far from enough. You need to learn more about Python to stand out from the interview.

Articles you may be interested in:
  • Use webqq protocol to use python to log on to qq and send the source code reference
  • Example of using python to call java Webservice
  • Python FizzBuzzWhizz (checklist) Example
  • Python Web server Tornado usage Summary
  • Analysis of communication examples between Python and js clients through websocket
  • Share the simple Performance Test Results of common python web frameworks (including django, flask, bottle, tornado)
  • A super simple python web program
  • Python + mysql implement simple web programs
  • An example of getting started with website development under the Python Web framework Flask
  • Python engineer interview questions related to Python Web

Related Article

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.