JP Morgan & Chase interview questions and answers
My experience and what I learned. This is a part of my job interviews series. On the ORR (outer ring road), JPMC has a big office. It took me some time to reach the designated building. I used to stay at BTM during that time. Before the physical discussion, I had a telephonic round. It was delayed by 1 hour due to some availability issues. You may check this GeekForGeeks page for more clarity. What are Decorators and why do you use them? What is a Context manager? When to use Decorator and Context manager? This is one of the best answers out there by Martijn Pieters They are completely separate concepts and should not be seen in the same light. A decorator lets you augment or replace a function or a class when it is defined. This is far broader than just executing things before or after a function call. Sure, your specific decorator lets you do something just before and after a function call, provided no exception is raised, or you explicitly handle exceptions. But you could also use a decorator to add an attribute to the function object or to update some kind of registry. Or to return something entirely different and ignore the original function. Or to produce a wrapper that manipulates the arguments passed in, or the return value of the original function. A context manager can’t do any of those things. A context manager on the other hand lets you abstract away try: … finally: constructs, in that no matter how the block exits, you get to execute some more code at the end of the block. Even if the block raises an exception, or uses return to exit a function, the context manager The two concepts are otherwise not related at all. Use decorators when you require to do something to or with functions or classes when they are defined. Use context managers when you want to clean up or take other actions after a block ends. This was a physical interview. Three, Four people came and started interviewing me. Initially felt a bit nervous about watching so many people. Usually 1 or 2 interviewers I used to face. Anyway, I adapted to the situation calmed myself as needed. Shallow copying with example Making a shallow copy of an object won’t clone child objects. Therefore, the copy is not fully independent of the original. A deep copy of an object will recursively clone child objects. The clone is fully independent of the original, but creating a deep copy is slower. You can copy arbitrary objects (including custom classes) with the copy module. Design Patterns used in Python Convert a string to a list without a list() or list expression Not selected for next round. I have been escorted back to the ground floor by one of the interviewers. I have appeared in 20+ interviews so far. You can check out my job interview series for the rest of the interviews experiences. Let me know if you have any further questions. Thank You. Cover pic by Ravi Shankar JP Morgan & Chase interview questions and answers
Background
First round of discussion
classmethod
vs staticmethod
; where and how did you implement it?input: [1,2,3,4,5,6]
and output: [[1,2], [3,4], [5,6]]
how can you get the output with the help of a list expression?>>> =
>>> =
>>>
timing
decorator to get the execution time of a function/method. For a complex case where I had used lru_cache
with a timeout limit, check out this article.__exit__
method is still going to be called, regardless. A context manager can even suppress any exceptions raised in the block. Second round of discussion
source: GeekForGeeks
Result
Opinion