Skip to main content

Python interview questions. Part III. Senior Level


 


Questions

Q: Python is always called an easy language. Will you agree with it?

Q: What are the pitfalls and problems of Python language?

Q: How does a framework differ from a library?

Q: Is it possible to use the construction True = False?

Q: When will the else part of try...except...else be executed?

Q: What is monkey patching? How to use it in Python? Example? Is it ever a good idea?

Q: How are dict and set implemented internally? What is the complexity of retrieving an item? How much memory do these structures consume?

Q: Does Python support multiple inheritance? How does it solve the diamond problem?

Q: What is MRO in Python? How does it work?

Q: Does Python have an assignment operator? How is the assignment process in Python different from C/C++?

Q: What are descriptors? Is there a difference between a descriptor and a decorator?

Q: How are arguments passed to a function in Python — by value or by reference?

Q: What tools help you find code smells in code or perform static Code analysis? What else do you know/use to make your code maintainable and readable?

Q: Whenever Python exits, why isn't all the memory de-allocated?

Q: Is it possible to have a producer thread reading from the network and a consumer thread writing to a file, really work in parallel? What about GIL?

Q: What is GIL? Why GIL still exists?

Q: What is string interning? Why it Python have it?

Q: Why Python doesn't have a tail recursion optimization? How to implement it?

Q: What is the process of compilation and linking in Python?

Q: How to distribute Python code?

Q: How to package code in Python?

Q: What is a package manager? What package managers do you know, and which one do you recommend?

Q: How to work with Python transitive dependencies?

Q: What are the wheels and eggs? What is the difference?

Q: How to package binary dependencies in Python?

Q: What is Cython? What is IronPython? What is PyPy? Why do they still exist?

Q: Explain how can you access a module written in Python from C? Vise versa?

Q: What is __pycache__? What are .pyc files?

Q: How to speed up existing Python code? How would you speed up your, say, web app?

Q: How to isolate Python code? What are virtualenvs?

Q: Is Python a functional language? Specify the requirements for code written in a functional paradigm.

Q: Identify the pitfalls/limitations of the functional code.

Q: What are .pth files?

Q: What advantages do NumPy arrays offer over (nested) Python lists?

Q: What does the PYTHONOPTIMIZE flag do?

Q: You have a memory leak in the working production application on one of your company servers. How would you start debugging it?

Code involving questions

Q: Give an example of a filter and reduce over an iterable object.

Q: Write a function that reverses the generator?

Q: You need to implement a function that should use a static variable (for example, a call counter). You cannot write any code outside the function and you do not have information about external variables (outside your function). How to do it?

Q: What methods and in what order are called when print (A() + B()) is executed?

Q: How to implement a dictionary from scratch using core Python?

Q: What's the output?

def Foo(): 
    yield 42;
    return 666

Q: What will be the output of the following code?

>>> a = [[]] * 3
>>> a[1].append(1)
>>> print(a)  # [[1], [1], [1]

Q: Place the following functions below in order of their efficiency. How would you test your answer?

def f1(arr):
    l1 = sorted(arr)
    l2 = [i for i in l1 if i < 0.5]
    return [i * i for i in l2]
def f2(arr):
    l1 = [i for i in arr if i<0.5]
    l2 = sorted(l1)
    return [i * i for i in l2]
def f3(arr):
    l1 = [i * i for i in arr]
    l2 = sorted(l1)
    return [i for i in l1 if i < (0.5*0.5)]

Q: Write a one-liner that will count the number of capital letters in a file. Your code should work even if the file is too big to fit in memory.

Q: What will be the output of the following code? Why? Is this inheritance?

class C:
    pass

type (C())
type (C)

Q: What will be the output of the following code?

big_num_1   = 1000
big_num_2   = 1000
small_num_1 = 1
small_num_2 = 1
big_num_1 is big_num_2
small_num_1 is small_num_2

Q: How is this possible?

_MangledGlobal__mangled = 23

class MangledGlobal:
     def test(self):
         return __mangled

>>> MangledGlobal().test()
23

Q: What will be the output of the following code?

>>> print(_)

Q: You saw the following piece of code. What is wrong with this code? Why is it needed?

if __debug__:
    assert False, ("error")

Comments

Popular posts from this blog

Data Analysis Interview Question Basic+Adv

  1.    Behavioral Questions : ·     Tell me about a time when you had to analyze a large set of data. How did you approach it, and what was the outcome? ·       Describe a situation where you had to work on a project with tight deadlines. How did you prioritize your tasks? ·       Can you discuss a time when you faced a significant challenge while working in a team? How did you handle it? 2.    Analytical Questions : ·       How would you determine the success of a new product launch on Amazon? ·       If given sales data, how would you identify trends and make recommendations to improve sales performance? ·       How would you assess the impact of changes in pricing on customer behavior and sales? 3.    Case Study/Problem-Solving Scenarios : ·       Analyze a dataset showing customer purchase behavior on Amazon and suggest strategies to increase customer engagement or retention. ·       Given fluctuating sales figures for a particular product category, what factors would you consider

Bytemetrics Solutions Internship 2024 For Data Analyst / Analysis | Work From Home

  Bytemetrics Solutions Internship 2024:  Bytemetrics Solutions Internship 2024 for its Data Analyst / Analysis. Bytemetrics Solutions Internship Drive organizes off-campus drives for candidates in any batch. To apply, candidates should have a Graduate. if you are interested, please apply as soon as possible. Company Name: Bytemetrics Solutions Role: Data Analyst / Analysis Location: Remote Experience: 0 – 1 years Qualification: Graduate Batch: Any Job Type: Full Time Salary: INR 400,000 – 500,000 Bytemetrics Solutions Internship 2024 Job Description: As a Data Analyst at Color Paper India Pvt Ltd you will have the opportunity to gain hands-on experience in data analysis and contribute to real-world projects. Requirements: Currently enrolled in or recent graduate of a relevant academic program. Strong analytical skills with attention to detail. Proficiency in data analysis tools such as Excel, SQL, or Python (preferred but not required). Excellent communication and teamwork skills. Abi

PubMatic Recruitment 2024 for Software Engineer – Data Analytics

PubMatic Recruitment 2024 for its Software Engineer – Data Analytics, PubMatic Drive is organizing Off Campus Drive for candidates in the 2023 Batch. In order to apply, candidates should have a degree in B.E/B.Tech/MCA Degree. If you are interested, Please apply as soon as possible. Company Name: PubMatic Role: Software Engineer – Data Analytics Location: Pune Experience: Freshers Qualification: B.E/B.Tech/MCA Batch: 2023 Batch Job Type: Full Time Salary: Rs.10LPA(Expected) PubMatic Recruitment 2024 Job Description: PubMatic is hiring candidates who can design and implement next-generation highly scalable, distributed, and low-latency applications. If you get excited building applications and architecture to handle 100’s billions of requests per day, managing millions of requests per second with a creative and fast-paced work environment, competitive pay, great incentives, a culture of teamwork, smart and friendly colleagues, and plenty of opportunity to grow in your career then you sh