Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the Python-related interview questions?

2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what are the Python-related interview questions". In the daily operation, I believe many people have doubts about the Python-related interview questions. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "what are the Python-related interview questions?" Next, please follow the editor to study!

16. China, use regular matching to match the content in the tag ("China"), in which the class name of class is uncertain.

17. Examples of python interrupt method

Assert () method, if the assertion is successful, the program continues to execute, and if the assertion fails, the program reports an error

18. The data table student has an id,name,score,city field, in which the name in name may be duplicated, and the duplicate rows need to be eliminated. Please write a sql statement

Select distinct name from student

19. 10 common Linux commands

Ls pwd cd touch rm mkdir tree cp mv cat more grep echo

20. The difference between python2 and python3? List 5

1. Python3 must print content wrapped in parentheses when using print, such as print ('hi').

Python2 can use either parentheses or a space to separate the printed content, such as print 'hi'

2. Python2 range returns a list, while python3 returns an iterator to save memory

3. Ascii coding is used in python2 and utf-8 coding is used in python.

4. Unicode represents string sequence and str represents byte sequence in python2

In python3, str represents a string sequence and byte represents a byte sequence.

5. For normal display of Chinese in python2, introduce coding declaration, which is not required in python3.

6. In python2 is the raw_input () function, and in python3 is the input () function

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

Immutable data types: numeric, string string, and tuple tuple

The value of the variable is not allowed to change. If you change the value of the variable, it is equivalent to creating a new object, but for an object with the same value, there is only one object (an address) in memory. The following figure uses the id () method to print the id of the object.

Variable data types: list list and dictionary dict

Allow the value of the variable to change, that is, if you only change the value of the variable after append, + =, etc., instead of creating a new object, the address of the object referenced by the variable will not change, but for different objects with the same value, there will be different objects in memory, that is, each object has its own address, which is equivalent to saving multiple copies of objects with the same value in memory. There is no reference count, it is a real object.

22, s = "ajldjlajfdljfddd", remove duplicates and sort "adfjl" from small to large

Set de-weight, de-re-converted to list, using the sort method to sort, reeverse=False is from small to large

List is an immutable data type, and there is no return value for s.sort, so the comments are written incorrectly.

23. Multiply two numbers with lambda function

24. The dictionary sorts from smallest to largest according to the key.

Dic= {"name": "zs", "age": 18, "city": "Shenzhen", "tel": "1362626627"}

25. Use the Counter method of 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". There is a space in the middle of each word. Filter out English and numbers with rules, and finally output "Zhang San Shenzhen".

By the way, paste the code that matches the decimal number, although it can match, but the robustness needs to be further confirmed.

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

The filter () function is used to filter sequences, filter out elements that do not meet the criteria, and return a new list of eligible elements. It receives two parameters, the first is a function, the second is a sequence, each element of the sequence is passed as a parameter to the function for judgment, then returns True or False, and finally puts the element that returns True into the new list

28. List derivation to find all odd numbers in the list and construct a new list, a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

29. Regular re.complie function

Re.compile is about compiling regular expressions into an object, speeding up and reusing

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

At this point, the study of "what are the Python-related interview questions" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report