2021 Python must brush interview questions (with answers)

Here, the host shamelessly recommends the WeChat official account "Python Geek Thinking". The official account will continue to publish various high-paying positions in big factories, including but not limited to Python positions (introduction). Welcome to the old iron to discuss and exchange~~ .

Scan the QR code below on WeChat to get detailed answers in PDF version. And reply to Python interview questions

 

1. One line of code realizes the sum of 1-100

2. How to modify global variables inside a function

3. List 5 python standard libraries

4. How the dictionary deletes keys and merges two dictionaries

5. Talk about python's GIL

6. How to implement list de-duplication in python

7. What does *args, **kwargs in fun(*args,**kwargs) mean?

8. The difference between python2 and python3 range (100)

9. Explain in one sentence what kind of language can use decorators?

10. What are the built-in data types in python

11. Briefly describe the difference between __new__ and __init__ in object-oriented

12. Briefly describe what the with method has done for me to open the processing file?

13. List [1,2,3,4,5], please use map() function to output [1,4,9,16,25], and use list comprehension to extract numbers greater than 10, and finally output [16 ,25]

14. The method of generating random integers, random decimals, and decimals between 0 and 1 in python

15. Avoid escaping. Which letter should be added to the string to represent the original string?

16. <div class="nam">China</div>, use regular matching to match the content in the tag ("China"), where the class name of the class is uncertain

17. Examples of python assertion methods

18. The student data table has id, name, score, and city fields. The name in the name can be repeated. If you need to eliminate duplicate rows, please write a SQL statement

19.10 common Linux commands

20. What is the difference between python2 and python3? List 5

21. List the variable data types and immutable data types in python, and briefly describe the principles

22. s = "ajldjlajfdljfddd", de-duplicate and sort output "adfjl" from small to large

23. Use lambda function to multiply two numbers

24. The dictionary is sorted according to the key from smallest to largest dict={"name":"zs","age":18,"city":"Shenzhen","tel":"1362626627"}

25. Use the Counter method of the collections library to count the number of occurrences of each word in the string "kjalfj;ldsjafl;hdsllfdhg;lahfbl;hl;ahlf;h"

26. The string a = "not 404 found Zhang San 99 Shenzhen", with a space in the middle of each word, filter out English and numbers with regular rules, and finally output "Zhang San Shenzhen"

27. The filter method finds all odd numbers in the list and constructs a new list, a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

28. List comprehension finds all odd numbers in the list and constructs a new list, a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

29, regular re.complie function

30. What type of data are a=(1,) b=(1), c=("1")?

31. Two lists [1,5,7,9] and [2,2,6,8] are merged into [1,2,2,3,6,7,8,9]

32. Use python to delete files and use linux commands to delete files

33. In the log log, we need to record the occurrence time of error, warning, etc. with a timestamp. Please use the datetime module to print the current timestamp "2018-04-01 11:38:54"

34. Database optimization query method

35. Please list any open source libraries that you can use to draw statistical graphs (bar graphs, line graphs, etc.), and third parties are also OK

36, write a custom exception code

37. In regular expression matching, what is the difference between (.) and (.?) matching?

38. Briefly describe Django's orm

39. [[1,2],[3,4],[5,6]] a line of code to expand the list, get [1,2,3,4,5,6]

40. x=”abc”,y=”def”,z=[“d”,”e”,”f”], respectively find the results returned by x.join(y) and x.join(z)

41. Illustrate the relevant meaning of try except else finally in the exception module

42. Exchange two values ​​in python

43. Illustrate the usage of zip() function with examples

44. a=”Zhangming 98 points”, use re.sub to replace 98 with 100

45. Write 5 commonly used SQL statements

46, a=”hello” and b=”hello” are encoded into bytes type

47. What is the result of [1,2,3]+[4,5,6]?

48. Ways to improve the efficiency of python operation

49. Briefly describe the difference between mysql and redis

50. How to deal with bugs

51. 1. Regular matching, matching date 2018-03-20
url='https://sycm.taobao.com/bda/tradinganaly/overview/get_summary.json?dateRange=2018-03-20%7C2018-03-20&dateType =recent1&device=1&token=ff25b109b&_=1521595613462'

52. list=[2,3,5,4,9,6], sort from small to large, sort is not allowed, output [2,3,4,5,6,9]

53, write a single column mode

54. Keep two decimal places. The
question itself only has a=”%.03f”%1.3335. Let’s calculate the result of a. In order to expand the idea of ​​keeping decimals, provide the round method (number, reserved digits)

55, find three methods to print the results

56. List common status codes and meanings

57. Explain the performance optimization of web projects from the front-end, back-end, and database respectively

58. Use pop and del to delete the "name" field in the dictionary, dic={"name":"zs","age":18}

59. List common MYSQL data storage engines

60. Calculate the results of the code execution. The zip function history article has already said that [("a",1),("b",2), ("c",3),("d",4), ("E",5)]

61. Briefly describe the same-origin strategy

62. Briefly describe the difference between cookie and session

63. Briefly describe multi-threading and multi-process

64. Briefly describe the any() and all() methods

65. What are the exceptions represented by IOError, AttributeError, ImportError, IndentationError, IndexError, KeyError, SyntaxError, and NameError respectively

66. The difference between copy and deepcopy in python

67. List several magic methods and briefly introduce their uses

68. C:\Users\ry-wu.junya\Desktop>python 1.py 22 33 command line to start the program and pass parameters, what data will print (sys.argv) output?

69. Please change [i for i in range(3)] to generator

70. a = "hehheh", remove the closing spaces

71. For example, sort and sorted sort the list, list=[0,-1,3,-10,5,9]

72. Sort the list foo = [-5,8,0,4,9,-4,-20,-2,8,2,-4], use the lambda function to sort from small to large

73. Use the lambda function to sort the list foo = [-5,8,0,4,9,-4,-20,-2,8,2,-4], the output result is
[0,2,4,8 ,8,9,-2,-4,-4,-5,-20], positive numbers from small to large, negative numbers from large to small

74. The sorting of the nested dictionary of the list is sorted according to age and name

75. List nested tuples, sorted by letters and numbers respectively

76. What should I do if the list is sorted in a nested list and the age numbers are the same?

77. Sort the dictionary according to the key (Method 1, zip function)

78. Sort the dictionary according to the key (method two, no need to zip)

79. List comprehensions, dictionary comprehensions, generators

80. Finally, a test question is issued, sorted according to the length of the string to see if the sorting is used flexibly

81. Illustrate SQL injection and solutions

82. s=”info:xiaoZhang 33 shandong”, use regular split string output ['info','xiaoZhang', '33','shandong']

83. Regular matching of mailboxes ending in 163.com

84, recursive summation

85. Python dictionary and json string mutual conversion method

86. The difference between MyISAM and InnoDB:

87. Count the number of occurrences of a character in a string

88. String conversion case

89. Use two methods to remove spaces

90. Regular matching of mobile phone numbers that do not end in 4 and 7

91. Briefly describe the python reference counting mechanism

92. What is the output result of int("1.4"),int(1.4)?

93. List more than 3 PEP8 coding specifications

94. Regular expression matches the first URL

95, regular matching Chinese

96. Briefly describe optimistic locks and pessimistic locks

97, r, r+, rb, rb+ file open mode difference

98. Linux command redirection> and >>

99. The regular expression matches <html><h1>www.itcast.cn</h1></html>

100. Is the python parameter passed by value or by address?


101. Find the intersection, difference, and union of two lists

102. Generate random numbers from 0-100

103, lambda anonymous function benefits

104. Common network transmission protocols

105, single quotation mark, double quotation mark, triple quotation mark usage

106, python garbage collection mechanism

107. The difference between get and post in HTTP requests

108. The method of reading Excel files in python

109. Briefly describe multi-threading and multi-process

110, search and match in python regular

 

Here, the host shamelessly recommends the WeChat official account "Python Geek Thinking". The official account will continue to publish various high-paying positions in big factories, including but not limited to Python positions (introduction). Welcome to the old iron to discuss and exchange~~ .

Scan the QR code below on WeChat to get detailed answers in PDF version. And reply to Python interview questions

                                                           



 

Guess you like

Origin blog.csdn.net/youyouxiong/article/details/114251010