wedge
For recently, and I come into contact with a few classmates have also tried to go to the market of water, have to say because of the influence of the outbreak, led to the current medium level developers’ with a little difficult, after all, not everyone can go to a second line of large, sometimes the waves of the sea is too big, we have to pack up the sail, thrashing about, harbor dormant, Therefore, we can focus on some positions with relatively low requirements, such as outsourcing positions. Of course, there are some prejudices and low evaluations of outsourcing companies in the industry. Objectively speaking, outsourcing companies do have some unsatisfactory places, but there are also some benefits can not be ignored: Projects such as contact, contact more people, the accumulation of experience is fast, suitable for people who want to accumulate experience, and have an opportunity to enter the party a, if the business is doing good, have the opportunity to enter the company of party a, party a if it is a big word directly into the generally don’t go after but through outsourcing in certain probability can turn to party a, can yet be regarded as a curve route for saving. Pactera is the leading outsourcing company at home and abroad, and its interview questions are relatively representative. Here, we analyze and summarize the interview questions of Pactera for outsourcing jobs. The technical stack is mainly Python, supplemented by some simple front-end knowledge points.
The interview questions
1. Introduce yourself
About introduce myself this is nagging question of the introduction of a lot of people are stereotypes, such as my name is XXX, this year, a few years in a company do what, in fact, all these basic information on your resume has been clearly identified, so introduce yourself entirely to say something on your resume doesn’t say, like a recent focus on new technology, can tell me about yourself For some of the latest industry news what are their opinions, also can use link take the initiative to strike up a conversation with the interviewer, introduce yourself and ask their hometown, where is the first and the interviewer simple communication can judge where the interviewer concerns, such as it is attention to detail or looking at the big picture, provided a basis for the following interview questions.
2. Difference between range and Xrange
Python3 does not have the xrange method anymore. The previous xrange method has been renamed range. In the Python2 era, the xrange method has been renamed range. Range returns a list of all the elements. Xrange returns a generator. A generator is an iterable, and the elements are created one by one as we iterate over the generator. The list needs to carve out the corresponding memory space for traversal according to the length of the list. Generally speaking, when iterating on large sequences, xrange can save memory due to its characteristics.
3. Talk about deep and light copies of Python
Shallow copy does not affect the original object, but deep copy does not. Shallow copy does not affect the original object
1. Copy immutable objects: Simply add a reference to the original object, and the changes will affect each other.
>>> a = (1, 2, [3, 4]) >>> b = copy.copy(a) >>> b ... (1, 2, 3, 4])# Change one side and change the other>>> b[2].append(5) >>> a ... (1, 2 [3, 4, 5])Copy the code
2. Copy variable objects (one layer structure) : generate new objects, open up new memory space, change each other.
>>> import copy
>>> a = [1, 2, 3]
>>> b = copy.copy(a)
>>> b
... [1, 2, 3]
# check the memory address of the two, different, open up new memory space
>>> id(b)
... 1833997595272
>>> id(a)
... 1833997595080
>>> a is b
... False
# Change one side, the other side is none of my business
a = [1, 2, 3] b = [1, 2, 3]
>>> b.append(4)
>>> a
... [1, 2, 3]
>>> a.append(5)
>>> b
... [1, 2, 3, 4]
Copy the code
3. Copy variable objects (multi-layer structure) : generate new objects, open up new memory space, do not change the contained child objects will not affect each other, change the contained child objects will affect each other.
>>> import copy >>> a = [1, 2, [3, 4]] >>> b = copy.copy(a) >>> b ... [1, 2, 3, 4]# check the memory address of the two, different, open up new memory space
>>> id(b)
1833997596488
>>> id(a)
1833997596424
>>> a is b
... False
# 1. There are no modifications to the contained child objects, the other side is my business
a = [1, 2, [3, 4]] b = [1, 2, [3, 4]]
>>> b.append(5)
>>> a
... [1, 2, [3, 4]]
>>> a.append(6)
>>> b
... [1, 2, [3, 4], 5]
# 2. Modify the contained child object, and the other party changes accordinglya = [1, 2, [3, 4]] b = [1, 2, [3, 4]] >>> b[2].append(5) >>> a ... [1, 2, [3, 4, 5]] >>> a[2].append(6) >>> b ... [1, 2, [3, 4, 5, 6]Copy the code
4. Tell me about memory management in Python
Memory management is also a classic high-frequency interview questions, using a language, if you do not understand its memory management mechanism, obviously a little difficult to say, later code performance optimization may be unable to do. Python has a private heap space to hold all objects and data structures. As developers, we don’t have access to it; the interpreter manages it. But with the core API, we can access some tools. The Python memory manager controls memory allocation.
In addition, the built-in garbage collector reclaims all unused memory, so make it suitable for heap space.
Garbage collection: unlike C++, Java, etc., python can assign values to variables without declaring their types. In Python, object types and memory are determined at run time. This is why we call the Python language dynamic typing (here dynamic typing simply boils down to assigning memory addresses to variables that are automatically typed at run time).
Reference counting: Python manages memory in a similar way to Windows kernel objects. Each object maintains a count of references to that pair of objects. When a variable is bound to an object, the reference count of the variable is 1 (there are other situations where the reference count of the variable can be increased). The system automatically maintains these labels and periodically scans them. When the reference count of a label goes to 0, the pair is reclaimed.
An object is going to keep track of how many references it’s getting and every time it adds a reference, its reference count is going to automatically increase by 1 and every time it decreases by a reference, its reference count is going to automatically decrease by -1
Reference count +1 scenario
1. The object is created p1 = Person() 2. The object is referenced p2 = p1 3log4. The object is stored as an element in the container l = [p1].Copy the code
Reference Count -1 scenario
3. An object leaves its scope. A function completes when the internal local variable is associated with the object, and its reference count is -1Copy the code
Viewing reference counts
import sys
class Person:
pass
p1 = Person() # 1
print(sys.getrefcount(p1)) # 2
p2 = p1 # 2
print(sys.getrefcount(p1)) # 3
del p2 # 1
print(sys.getrefcount(p1)) # 2
del p1
# print(sys.getrefcount(p1)) #error because the previous line of code has been destroyed>>>> Print the result 2 3 2Copy the code
Objects can’t be destroyed by reference counters manually triggering garbage collection, waving cyclic references
import objgraph
import gc
class Person:
pass
class Dog:
pass
p = Person()
d = Dog()
p.pet = d
d.master = p
del p
del d
gc.collect() Manually trigger garbage collection
print(objgraph.count("Person"))
print(objgraph.count("Dog")) >>>> 0 0 is printedCopy the code
5. Please talk about the difference between Django and Flask web frameworks
This kind of open-ended question can be answered briefly according to your cognition:
1.Django takes a broad and comprehensive approach to development and is efficient. Its MTV framework, its own ORM, Admin background management, its own SQLite database and development test server to improve the development of ultra-high efficiency
2.Flask is a lightweight framework, free, flexible and highly scalable. The core is based on Werkzeug WSGI tools and Jinja2 template engine
Flask is like a car, you can go about it, you can change the tyres, you can change the tyres, you can change the tyres, you can change the tyres, you can change the tyres, you can change the tyres.
And Django is more like a train, the train although and move forward, can only rely on track route is relatively rigid, but the train has a variety of cabin services, such as toilet, dining, sleeping and so on, this corresponds to the orm, admin and other built-in module, do not need to make the wheels, but must be conducted in accordance with relevant provisions of the framework of the way, You lose your freedom, more or less.
conclusion
In general, the interview of Pactera is relatively basic, without complex questions combining algorithms with scenes, and without the popular leetcode original questions in the market, so the probability of getting an offer is definitely higher than that of first-tier companies. But to be fair, if you get an offer from outsourcing companies, don’t just focus on the immediate. I will continue my efforts and strive for a chance to go to Dachang. Finally, I attach a knowledge architecture diagram of Python full stack