In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain to you in detail what are the Python questions that are not common in the interview, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
Analysis of Python interview questions
Editor's note:
Coincides with the gold, silver and silver recruitment season, many friends are busy job-hopping, constant interviews. We know that there are many kinds of questions on the Internet, but they are often old questions from a few years ago. In order to help friends stand out in the Python job interview, I would like to present 11 questions and answers to the 2019 Python interview.
1. Please write the function find_string in python to search for and print content from the text, requiring support for wildcard asterisks and question marks.
Example:
> find_string ('hello\ nworld\ npreceptors') ['wor'] > find_string (' hello\ nworld\ npreceptors') ['ld'] > find_string (' hello\ nworld\ ngrammes') ['or']
Parsing:
Def find_string (str_in,pat): import re return re.findall (pat,str_in,re.I)
2. Look at the words on your T-shirt: life is short. I use Python. Can you tell me what kind of language Python is? You can compare other technologies or languages to answer your questions.
Parsing:
Here are some key points: Python is an interpreted language. This means that unlike C and other languages, Python does not need to be compiled before it can be run. Other interpretive languages include PHP and Ruby.
1.Python is dynamically typed, which means you don't need to specify a type when you declare a variable. You can first define xan111, and then x = "I'm a string".
2.Python is an object-oriented language that allows classes to be defined and can be inherited and combined. Python does not have access tags such as public and private in C++, so it trusts the quality of programmers very much and believes that every programmer is an "adult" ~
3. In Python, functions are first-class citizens. This means that they can be assigned, return values from other functions, and pass function objects. Class is not a first-class citizen.
4. Writing Python code is fast, but it runs slower than compiled languages. Fortunately, Python allows you to write programs using C extensions, so bottlenecks can be addressed. The Numpy library is a good example, because a lot of code is not written directly by Python, so it runs very fast.
5.Python is used in many scenarios-web application development, big data application, data science, artificial intelligence and so on. It is also often seen as a "glue" language, making it possible to connect different languages.
6.Python simplifies work, allowing programmers to care about how to rewrite code instead of looking at the underlying implementation in detail.
Source of this question: @ David 9, link: http://nooverfit.com/wp/15
3. Please write a piece of Python code to delete the duplicate elements in a list.
Parsing:
1. Use the set function, set (list)
two。 Use dictionary function
> a = [1, b=b.fromkeys 2, 4, 4, 5, 5, 5, 5, 7, 8, 9, 0] > > b = {} > b=b.fromkeys (a) > c=list (b.keys ()) > c
Source of this question: @ Tom_junsong
4. A = [1, 2, 4, 4, 5, 7, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
Parsing:
A.sort () last=a [- 1] for i inrange (len (a)-2 if last==a [I]: del a [I] else:last=a [I] print (a)
Source of this question: @ Tom_junsong
5. How to generate random numbers in Python?
Parsing:
Random module
Random integers: random.randint (aforme b): returns random integers xmema > axim lambdaxrecy > a (3meme 11).
8.-enter a string to return a string that meets the following conditions
-A string consisting of the first two letters of a string and the two letters of *.
-for example: 'spring' returns' spng', 'is' returns' is'
-returns an empty string when the length of the entered string is less than 2
Parsing:
S=input ('input:') l=len (s) if L3: Stiles [: 2] + s [- 2:] print (s)
9. Decompose each composite number into the form of multiplying several prime numbers, for example, 100, 2, 2, 5, 5, and package the code into the form of a function.
Parsing:
Def f (n): result = [] I = 2 str1 = str (n) +'= 'while n > 1: if n% I = = 0: n / = I result.append (str (I)) I-= 1 I + = 1 str1 + =' * '.join (result) return str1 if _ name__ = =' _ main__': for i in range 120): print (f (I))
To decompose the prime factor of n, we should first find a minimum prime number k, and then follow the following steps:
(1) if the prime number is exactly equal to n, then the process of decomposing the prime factor is over and can be printed out.
(2) if nk, but n is divisible by k, you should print out the value of k and divide n by the quotient of k as the new positive integer you n, repeat the * * step.
(3) if n is not divisible by k, the * * step is repeated by using KQ 1 as the value of k.
10. Please use Python handwriting to sort bubbles.
Parsing:
The principle of bubble sorting is not difficult, assuming that the sorted array R [1... n] is arranged vertically from large to small, and each number R can be regarded as a bubble with a weight of R.key.
According to the principle of light bubbles on top and heavy bubbles on top, scan the array R from bottom to top: whenever light bubbles that violate this principle are scanned, make them float upward. This is repeated until any two bubbles are light at the top and heavy at the bottom.
Then all the bubbles are reversed, and the array is sorted from small to large.
Steps:
1 compare adjacent elements. If one is bigger than the second, exchange the two of them.
2 do the same work for the 0 th to the n-1 data. At this point, the number of * is at the position of the array.
3 repeat the above steps for all elements, except for one.
4 continue to repeat the above steps for fewer and fewer elements each time until there are no pairs of numbers to compare.
Python implementation
Def bubble_sort (arry): # get the length of the array n = len (arry) for i in range (n): for j in range (1) NMuri): # if the former is larger than the latter, if arry [j-1] > arry [j]: # then exchange the two arry [j-1], arry [j] = arry [j], Arry [j-1] return arry
11.-determine whether it is a palindrome or not
-hint: palindrome: 62426 is a palindrome number
Parsing:
S=input ('pls input a string of numbes:') swatches [::-1] answer='isn\' t'if slots: answer='is' print.
If you also want to see more interview questions about Python, we recommend that you click "read the original text" to the online AI interview question bank in July, which currently has thousands of AI interview questions parsing, covering all test sites, including machine learning, deep learning, Python, NLP, data mining, algorithms and so on.
About the interview is not common but will be asked which Python questions are shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.