{"id":25596196,"date":"2024-11-21T23:48:48","date_gmt":"2024-11-21T18:18:48","guid":{"rendered":"https:\/\/entri.app\/blog\/?p=25596196"},"modified":"2024-11-22T00:00:23","modified_gmt":"2024-11-21T18:30:23","slug":"ey-python-interview-questions","status":"publish","type":"post","link":"https:\/\/entri.app\/blog\/ey-python-interview-questions\/","title":{"rendered":"EY Python Interview Questions"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a03bb93a177d\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a03bb93a177d\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#Introduction_to_EY\" >Introduction to EY<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#Why_Join_EY\" >Why Join EY?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#Ey_Python_Interview_Preparation_Tips\" >Ey Python Interview Preparation Tips<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#Top_Ey_Python_Interview_Questions_and_Answers\" >Top Ey Python Interview Questions and Answers<\/a><\/li><\/ul><\/nav><\/div>\n<p>As the demand for skilled Python developers continues to grow, Ernst &amp; Young (EY), one of the &#8220;Big Four&#8221; accounting firms, seeks professionals who can not only write efficient code but also solve complex business problems using Python. EY interviews often cover a wide range of topics, from core Python concepts to advanced problem-solving techniques. Whether you&#8217;re a seasoned developer or preparing for your first technical interview, being well-versed in Python fundamentals, data manipulation, and problem-solving can give you a competitive edge.<\/p>\n<p>In this blog, we\u2019ll explore the top Python interview questions asked at EY. These questions focus on Python programming skills, object-oriented concepts, data structures, algorithms, and real-world applications in data analytics and automation.<\/p>\n<p style=\"text-align: center\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/course\/python-programming-course\/?utm_source=python-programming&amp;utm_medium=blog_referral&amp;utm_campaign=morgan-stanley-python-interview-questions\" target=\"_blank\" rel=\"noopener\">Get hands-on with our python course \u2013 sign up for a free demo!<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Introduction_to_EY\"><\/span><span data-sheets-root=\"1\"><strong>Introduction to EY<\/strong><br \/>\n<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Ernst &amp; Young (EY) is one of the largest professional services networks in the world, commonly recognized as one of the &#8220;Big Four&#8221; accounting firms, alongside Deloitte, PwC, and KPMG. Headquartered in London, EY provides a wide range of services including audit, tax, advisory, consulting, and transaction advisory services.<\/p>\n<h4><strong>Key Areas of Expertise:<\/strong><\/h4>\n<ul>\n<li><strong>Audit and Assurance<\/strong>: EY conducts independent audits and provides assurance services, ensuring the integrity of financial statements for businesses.<\/li>\n<li><strong>Tax Services<\/strong>: EY helps clients manage tax obligations while navigating the complexities of international tax law.<\/li>\n<li><strong>Advisory<\/strong>: The firm advises organizations on business strategies, operations, risk management, and IT implementations.<\/li>\n<li><strong>Consulting<\/strong>: EY offers management and business consulting services, with a focus on digital transformation, innovation, and data analytics.<\/li>\n<li><strong>Transaction Advisory<\/strong>: EY provides support for mergers and acquisitions (M&amp;A), capital transactions, and business restructuring.<\/li>\n<\/ul>\n<h4><strong>Global Reach:<\/strong><\/h4>\n<p>With offices in over 150 countries, EY operates a highly integrated global network, serving clients across various industries, including financial services, technology, healthcare, and consumer products.<\/p>\n<h4><strong>Focus on Innovation:<\/strong><\/h4>\n<p>EY is investing heavily in digital transformation, artificial intelligence, blockchain, and data analytics to help clients tackle challenges in an increasingly complex global business environment. They also offer services through EY wavespace, innovation centers that focus on co-creating digital solutions.<\/p>\n<h4><strong>Sustainability and Corporate Social Responsibility:<\/strong><\/h4>\n<p>EY is committed to driving sustainable growth, both for itself and its clients. The firm integrates environmental, social, and governance (ESG) factors into its business strategy and advisory services, aligning with global sustainability standards.<\/p>\n<p>EY aims to build a better working world by helping clients solve their toughest challenges while creating long-term value for society as a whole.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Why_Join_EY\"><\/span><span data-sheets-root=\"1\"><strong>Why Join EY?<\/strong><br \/>\n<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>There are several reasons why someone might consider joining Ernst &amp; Young (EY), one of the largest professional services firms in the world. Here are key points to consider:<\/p>\n<h4>1. <strong>Global Exposure<\/strong><\/h4>\n<ul>\n<li>EY operates in over 150 countries, providing employees with global opportunities to work with diverse teams, clients, and industries.<\/li>\n<li>Employees have the chance to travel and collaborate with teams worldwide, offering international exposure and experience.<\/li>\n<\/ul>\n<h4>2. <strong>Diverse Career Opportunities<\/strong><\/h4>\n<ul>\n<li>EY offers a broad range of services, including assurance, advisory, tax, and transaction advisory services. This diversity allows professionals to specialize in different areas or transition between sectors within the firm.<\/li>\n<li>Their global network enables employees to explore various career paths and industries, from financial services and technology to healthcare and government.<\/li>\n<\/ul>\n<h4>3. <strong>Strong Learning and Development Programs<\/strong><\/h4>\n<ul>\n<li>EY is known for its commitment to learning and development. The firm invests heavily in training, providing employees with access to certifications, leadership programs, and continuous education.<\/li>\n<li>Their <strong>EY Badges program<\/strong> allows employees to earn digital certifications in areas like <strong>data analytics<\/strong>, <strong>artificial intelligence (AI)<\/strong>, and <strong>blockchain<\/strong>.<\/li>\n<\/ul>\n<h4>4. <strong>Innovative Culture<\/strong><\/h4>\n<ul>\n<li>EY is committed to innovation and has been at the forefront of adopting technologies like <strong>AI<\/strong>, <strong>data analytics<\/strong>, and <strong>robotic process automation (RPA)<\/strong> in the consulting space.<\/li>\n<li>The firm has created environments to foster creativity and innovation through initiatives like <strong>EY wavespace<\/strong>, which are centers that bring together digital technologies, collaboration, and design thinking.<\/li>\n<\/ul>\n<h4>5. <strong>Inclusive and Diverse Workplace<\/strong><\/h4>\n<ul>\n<li>EY places a strong emphasis on diversity and inclusion. Their workforce is built on a commitment to promoting equal opportunities, fostering gender diversity, and supporting LGBTQ+ and other underrepresented groups through various employee networks.<\/li>\n<li>Their <strong>EY Women&#8217;s Network<\/strong> and initiatives promoting diversity are recognized globally.<\/li>\n<\/ul>\n<h4>6. <strong>Strong Ethical Foundation<\/strong><\/h4>\n<ul>\n<li>EY maintains a reputation for integrity and ethical business practices. They follow strict codes of conduct and place significant importance on sustainability and corporate social responsibility (CSR).<\/li>\n<li>They aim to create long-term value by focusing on sustainable growth, helping clients achieve their environmental, social, and governance (ESG) goals.<\/li>\n<\/ul>\n<h4>7. <strong>Work-Life Balance<\/strong><\/h4>\n<ul>\n<li>While consulting is generally known for its demanding hours, EY promotes flexible working arrangements, hybrid models, and initiatives to ensure employees can balance their personal and professional lives.<\/li>\n<li>EY also focuses on employee well-being, offering health benefits, mental health support, and various wellness programs.<\/li>\n<\/ul>\n<h4>8. <strong>Impactful Work<\/strong><\/h4>\n<ul>\n<li>EY provides an opportunity to work on impactful projects that help shape businesses and industries, advising some of the world\u2019s largest organizations on transformation, risk, and growth strategies.<\/li>\n<li>Employees can see the tangible results of their work on global businesses and economies.<\/li>\n<\/ul>\n<h4>9. <strong>Career Growth and Progression<\/strong><\/h4>\n<ul>\n<li>EY offers clear career development paths, enabling employees to grow into leadership roles. Their merit-based system rewards high performance and provides room for rapid career progression.<\/li>\n<li>Employees have access to mentorship and leadership development programs that help guide them through their career journey.<\/li>\n<\/ul>\n<h4>10. <strong>Corporate Social Responsibility<\/strong><\/h4>\n<ul>\n<li>EY has a strong focus on CSR, encouraging employees to get involved in their communities through volunteer programs and pro bono consulting services.<\/li>\n<li>The firm has initiatives aimed at improving education, equity, and entrepreneurship globally.<\/li>\n<\/ul>\n<p style=\"text-align: center\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/course\/python-programming-course\/?utm_source=python-programming&amp;utm_medium=blog_referral&amp;utm_campaign=morgan-stanley-python-interview-questions\" target=\"_blank\" rel=\"noopener\">Get hands-on with our python course \u2013 sign up for a free demo!<\/a><\/strong><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Ey_Python_Interview_Preparation_Tips\"><\/span><span data-sheets-root=\"1\">E<strong>y Python Interview Preparation Tips<\/strong><br \/>\n<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To prepare for a Python interview at EY (Ernst &amp; Young), it\u2019s important to focus on a combination of technical skills, problem-solving abilities, and practical experience. Here are some key tips to help you prepare:<\/p>\n<h4>1. <strong>Core Python Concepts<\/strong><\/h4>\n<ul>\n<li><strong>Data Types<\/strong>: Understand the core data types like <code>int<\/code>, <code>float<\/code>, <code>str<\/code>, <code>bool<\/code>, and their mutability. Be familiar with Python collections (<code>list<\/code>, <code>set<\/code>, <code>tuple<\/code>, <code>dict<\/code>).<\/li>\n<li><strong>Loops and Conditional Statements<\/strong>: Practice <code>for<\/code> loops, <code>while<\/code> loops, and conditional statements like <code>if-else<\/code>.<\/li>\n<li><strong>Functions and Scope<\/strong>: Be well-versed with defining and using functions, along with concepts like recursion, <code>*args<\/code>, <code>**kwargs<\/code>, global vs local scope.<\/li>\n<li><strong>List Comprehensions<\/strong>: Understand how to use list comprehensions and the differences between comprehensions and loops.<\/li>\n<\/ul>\n<h4>2. <strong>Object-Oriented Programming (OOP)<\/strong><\/h4>\n<ul>\n<li><strong>Classes and Objects<\/strong>: Review how to define classes, create objects, and understand the purpose of constructors (<code>__init__<\/code>).<\/li>\n<li><strong>Inheritance and Polymorphism<\/strong>: Be ready to explain inheritance (single, multiple, multilevel) and demonstrate how polymorphism works in Python.<\/li>\n<li><strong>Encapsulation and Abstraction<\/strong>: Understand how to use private and protected members and achieve abstraction with abstract classes or interfaces using <code>abc<\/code> module.<\/li>\n<li><strong>Magic\/Dunder Methods<\/strong>: Know how to use special methods like <code>__str__<\/code>, <code>__repr__<\/code>, <code>__eq__<\/code>, etc.<\/li>\n<\/ul>\n<h4>3. <strong>Data Structures and Algorithms<\/strong><\/h4>\n<ul>\n<li><strong>Data Structures<\/strong>: Study common data structures such as stacks, queues, linked lists, hash maps, trees, and graphs.<\/li>\n<li><strong>Algorithms<\/strong>: Focus on sorting algorithms (merge sort, quicksort), searching algorithms (binary search), and basic graph algorithms (BFS, DFS).<\/li>\n<li><strong>Time and Space Complexity<\/strong>: Be able to analyze the efficiency of your code using Big-O notation.<\/li>\n<\/ul>\n<h4>4. <strong>Error Handling and Exceptions<\/strong><\/h4>\n<ul>\n<li>Understand how to handle exceptions using <code>try-except-finally<\/code> blocks.<\/li>\n<li>Be familiar with raising custom exceptions and using <code>assert<\/code> statements.<\/li>\n<\/ul>\n<h4>5. <strong>Libraries and Frameworks<\/strong><\/h4>\n<ul>\n<li><strong>Standard Libraries<\/strong>: EY may focus on your knowledge of Python\u2019s standard libraries, including <code>math<\/code>, <code>collections<\/code>, <code>itertools<\/code>, <code>os<\/code>, <code>sys<\/code>, and <code>datetime<\/code>.<\/li>\n<li><strong>Popular Libraries<\/strong>: If the role requires knowledge in data science or web development, review libraries like <code>pandas<\/code>, <code>numpy<\/code>, <code>requests<\/code>, <code>flask<\/code>, <code>Django<\/code>, etc.<\/li>\n<\/ul>\n<h4>6. <strong>Database Interaction<\/strong><\/h4>\n<ul>\n<li>Be prepared to work with databases using Python. Understand how to connect to databases like MySQL, SQLite, or PostgreSQL using libraries like <code>sqlite3<\/code> or <code>SQLAlchemy<\/code>.<\/li>\n<li>Be familiar with basic SQL queries and how to execute them in Python.<\/li>\n<\/ul>\n<h4>7. <strong>Coding Practice<\/strong><\/h4>\n<ul>\n<li>EY is likely to focus on your problem-solving abilities. Practice coding problems on platforms like LeetCode, HackerRank, or CodeSignal.<\/li>\n<li>Focus on problems related to string manipulation, array processing, and recursive solutions.<\/li>\n<\/ul>\n<h4>8. <strong>Real-World Applications<\/strong><\/h4>\n<ul>\n<li>EY values practical experience. Be ready to explain how you\u2019ve used Python in real-world projects, particularly those involving automation, data analysis, or web development.<\/li>\n<li>Discuss any projects you\u2019ve worked on that demonstrate your ability to apply Python skills in a business context.<\/li>\n<\/ul>\n<h4>9. <strong>Behavioral Interview Preparation<\/strong><\/h4>\n<ul>\n<li>Prepare for behavioral questions related to teamwork, problem-solving under pressure, and how you approach learning new technologies.<\/li>\n<li>EY may ask about your ability to manage deadlines, work collaboratively in teams, and handle challenges in previous projects.<\/li>\n<\/ul>\n<h4>10. <strong>Mock Interviews and Technical Tests<\/strong><\/h4>\n<ul>\n<li>Practice technical problems under time constraints to simulate real interview conditions.<\/li>\n<li>EY may include coding assessments as part of the interview process, so take practice tests online to improve speed and accuracy.<\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Top_Ey_Python_Interview_Questions_and_Answers\"><\/span><span data-sheets-root=\"1\"><strong>Top Ey Python Interview Questions and Answers<\/strong><br \/>\n<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Here are the top 35 EY Python interview questions and answers, tailored for Python roles focusing on programming skills, object-oriented concepts, data structures, algorithms, and real-world applications in data analytics and automation:<\/p>\n<h5>1. <strong>What are Python\u2019s key features?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Python is an interpreted, high-level, dynamically typed language. Key features include simplicity, readability, extensive libraries, and support for object-oriented programming.<\/p>\n<h5>2. <strong>Explain Python&#8217;s memory management.<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Python uses automatic memory management through a private heap, garbage collection, and reference counting to manage memory allocation and deallocation.<\/p>\n<h5>3. <strong>What are decorators in Python?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Decorators are special functions in Python used to modify the behavior of another function or method without changing its actual code.<\/p>\n<h5>4. <strong>How does Python handle exceptions?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Python uses a try-except block to handle exceptions. Errors are caught in the except block to avoid program crashes.<\/p>\n<h5>5. <strong>What is the difference between a list and a tuple?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Lists are mutable, allowing modifications, whereas tuples are immutable and cannot be changed after creation.<\/p>\n<h5>6. <strong>What is a lambda function?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Lambda functions are small anonymous functions in Python, often used for short operations, defined using the keyword <code>lambda<\/code>.<\/p>\n<h5>7. <strong>Explain Python\u2019s Global Interpreter Lock (GIL).<\/strong><\/h5>\n<p><strong>Answer: <\/strong>The GIL is a mutex that protects access to Python objects, preventing multiple native threads from executing Python bytecode simultaneously in a single process.<\/p>\n<h5>8. <strong>What is the difference between deep copy and shallow copy?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>A shallow copy creates a new object but inserts references to the original objects. A deep copy creates a new object and recursively copies all objects, not just references.<\/p>\n<h5>9. <strong>What are Python iterators?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Iterators are objects that allow traversing through all the elements of a collection, like lists or tuples, using <code>__iter__()<\/code> and <code>__next__()<\/code> methods.<\/p>\n<h5>10. <strong>Explain list comprehensions.<\/strong><\/h5>\n<p><strong>Answer: <\/strong>List comprehensions provide a concise way to create lists by iterating over sequences and applying an expression to generate elements.<\/p>\n<h5>11.\u00a0<strong>What are Python generators?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Generators are functions that yield values one at a time using the <code>yield<\/code> keyword and maintain their state between each call.<\/p>\n<h5>12. <strong>How do you manage memory leaks in Python?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Memory leaks can be managed by using proper object referencing and ensuring that unused references are cleared, allowing Python&#8217;s garbage collector to reclaim memory.<\/p>\n<h5>13.\u00a0<strong>What is the difference between <code>__init__<\/code> and <code>__new__<\/code> in Python?<\/strong><\/h5>\n<p><strong>Answer:<\/strong> <code>__new__<\/code> is a static method used to create a new instance of a class, while <code>__init__<\/code> initializes the attributes of that instance.<\/p>\n<h5>14. <strong>Explain method overloading in Python.<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Python does not support traditional method overloading. However, it can be implemented using default arguments or by checking argument types.<\/p>\n<h5>15. <strong>What are closures in Python?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Closures are functions that capture and remember values from their enclosing scopes, even when the original scope is no longer present.<\/p>\n<h5>16. <strong>What is a Python module and how is it different from a package?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>A module is a single Python file that can contain functions and classes. A package is a collection of related modules grouped in a directory.<\/p>\n<h5>17. <strong>What is monkey patching in Python?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Monkey patching is a technique where you dynamically change or extend a module or class at runtime.<\/p>\n<h5>18. <strong>Explain the purpose of the <code>self<\/code> keyword in Python.<\/strong><\/h5>\n<p><strong>Answer:<\/strong> <code>self<\/code> represents the instance of the class and allows access to its attributes and methods within the class.<\/p>\n<h5>19. <strong>What is the use of <code>with<\/code> statement in Python?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>The <code>with<\/code> statement ensures that resources, like files, are properly managed and automatically closed after usage.<\/p>\n<h5>20. <strong>How do you handle missing data in Pandas?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Missing data can be handled using methods like <code>fillna()<\/code>, <code>dropna()<\/code>, and <code>interpolate()<\/code> in Pandas.<\/p>\n<h5>21. <strong>How do you merge two DataFrames in Pandas?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>DataFrames can be merged using the <code>merge()<\/code>, <code>join()<\/code>, or <code>concat()<\/code> methods in Pandas, depending on the type of operation needed.<\/p>\n<h5>22. <strong>What is the purpose of the <code>map()<\/code> function in Python?<\/strong><\/h5>\n<p><strong>Answer:<\/strong> <code>map()<\/code> applies a given function to all items in an iterable and returns a list of results.<\/p>\n<h5>23. <strong>Explain multithreading in Python.<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Multithreading in Python allows the execution of multiple threads concurrently but is limited by the GIL. Python\u2019s <code>threading<\/code> module handles thread-based parallelism.<\/p>\n<h5>24. <strong>What is the difference between NumPy arrays and lists?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>NumPy arrays are more efficient for numerical operations as they use less memory and provide faster access to elements than Python lists.<\/p>\n<h5>25. **What are *args and <strong>kwargs in Python?<\/strong><\/h5>\n<p><strong>Answer:<\/strong> <code>*args<\/code> allows passing a variable number of non-keyword arguments to a function, while <code>**kwargs<\/code> allows passing a variable number of keyword arguments.<\/p>\n<h5>26. <strong>What is data serialization in Python?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Data serialization is the process of converting data into a byte stream to store it or transmit it. Python supports serialization through the <code>pickle<\/code> module.<\/p>\n<h5>27. <strong>How would you implement a stack in Python?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>A stack can be implemented using a list in Python with <code>append()<\/code> for push operations and <code>pop()<\/code> for pop operations.<\/p>\n<h5>28. <strong>What is the difference between multithreading and multiprocessing?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Multithreading allows multiple threads to run concurrently within a process, while multiprocessing involves multiple processes, each with its own memory space.<\/p>\n<h5>29. <strong>Explain the <code>zip()<\/code> function in Python.<\/strong><\/h5>\n<p><strong>Answer: <\/strong>The <code>zip()<\/code> function combines two or more iterables (e.g., lists or tuples) into a single iterable of tuples, where the first element of each passed iterable forms the first tuple, and so on.<\/p>\n<h5>30. <strong>What is the <code>__repr__<\/code> method in Python?<\/strong><\/h5>\n<p><strong>Answer:<\/strong> <code>__repr__<\/code> provides a string representation of an object that can be used for debugging. It is meant to provide detailed information useful for developers.<\/p>\n<h5>31. <strong>How do you optimize the performance of a Python program?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Python program performance can be optimized by using efficient algorithms, minimizing I\/O operations, using built-in functions, and using libraries like NumPy for numerical computations.<\/p>\n<h5>32. <strong>What is the purpose of the <code>__name__ == '__main__'<\/code> construct?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>This construct allows you to check whether a Python script is being run directly or imported as a module into another script.<\/p>\n<h5>33. <strong>Explain method resolution order (MRO) in Python.<\/strong><\/h5>\n<p><strong>Answer: <\/strong>MRO determines the order in which base classes are searched when a method is called in the context of class inheritance. Python uses the C3 linearization algorithm for MRO.<\/p>\n<h5>34. <strong>What is the difference between <code>is<\/code> and <code>==<\/code> in Python?<\/strong><\/h5>\n<p><strong>Answer:<\/strong> <code>is<\/code> checks whether two variables refer to the same object in memory, while <code>==<\/code> checks if the values of the two variables are equal.<\/p>\n<h5>35. <strong>How do you create and handle a custom exception in Python?<\/strong><\/h5>\n<p><strong>Answer: <\/strong>Custom exceptions can be created by inheriting from the <code>Exception<\/code> class and overriding the constructor and <code>__str__<\/code> methods.<\/p>\n<p style=\"text-align: center\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/course\/python-programming-course\/?utm_source=python-programming&amp;utm_medium=blog_referral&amp;utm_campaign=morgan-stanley-python-interview-questions\" target=\"_blank\" rel=\"noopener\">Get hands-on with our python course \u2013 sign up for a free demo!<\/a><\/strong><\/p>\n<h3><strong>Python OOPS Interview Questions<\/strong><\/h3>\n<section id=\"how-will-you-check-if-a-class-is-a-child-of-another-class\" class=\"ibpage-article-header\">\n<h5><strong>1. How will you check if a class is a child of another class?<\/strong><\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>This is done by using a method called\u00a0issubclass()\u00a0provided by python. The method tells us if any class is a child of another class by returning true or false accordingly.<br \/>\n<strong>For example:<\/strong><\/p>\n<pre><code class=\"language-python hljs\"><span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Parent<\/span>(<span class=\"hljs-params\"><span class=\"hljs-built_in\">object<\/span><\/span>):<\/span>\r\n   <span class=\"hljs-keyword\">pass<\/span>   \r\n \r\n<span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">Child<\/span>(<span class=\"hljs-params\">Parent<\/span>):<\/span>\r\n   <span class=\"hljs-keyword\">pass<\/span>   \r\n \r\n<span class=\"hljs-comment\"># Driver Code<\/span>\r\n<span class=\"hljs-built_in\">print<\/span>(<span class=\"hljs-built_in\">issubclass<\/span>(Child, Parent))    <span class=\"hljs-comment\">#True<\/span>\r\n<span class=\"hljs-built_in\">print<\/span>(<span class=\"hljs-built_in\">issubclass<\/span>(Parent, Child))    <span class=\"hljs-comment\">#False<\/span><\/code><\/pre>\n<ul>\n<li>We can check if an object is an instance of a class by making use of\u00a0<strong>isinstance()<\/strong>\u00a0method:<\/li>\n<\/ul>\n<pre><code class=\"language-python hljs\">obj1 = Child()\r\nobj2 = Parent()\r\n<span class=\"hljs-built_in\">print<\/span>(<span class=\"hljs-built_in\">isinstance<\/span>(obj2, Child))    <span class=\"hljs-comment\">#False\u00a0<\/span>\r\n<span class=\"hljs-built_in\">print<\/span>(<span class=\"hljs-built_in\">isinstance<\/span>(obj2, Parent))   <span class=\"hljs-comment\">#True <\/span><\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"what-is-init-method-in-python\" class=\"ibpage-article-header\">\n<h5><strong>2. What is init method in python?<\/strong><\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>The\u00a0<strong>init<\/strong>\u00a0method works similarly to the constructors in Java. The method is run as soon as an object is instantiated. It is useful for initializing any attributes or default behaviour of the object at the time of instantiation.<br \/>\nFor example:<\/p>\n<pre><code class=\"language-python hljs\"><span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">InterviewbitEmployee<\/span>:<\/span>\r\n\r\n   <span class=\"hljs-comment\"># init method \/ constructor<\/span>\r\n   <span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">__init__<\/span>(<span class=\"hljs-params\">self, emp_name<\/span>):<\/span>\r\n       self.emp_name = emp_name\r\n\r\n   <span class=\"hljs-comment\"># introduce method<\/span>\r\n   <span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">introduce<\/span>(<span class=\"hljs-params\">self<\/span>):<\/span>\r\n       <span class=\"hljs-built_in\">print<\/span>(<span class=\"hljs-string\">'Hello, I am '<\/span>, self.emp_name)\r\n\r\nemp = EntriAppEmployee(<span class=\"hljs-string\">'Mr Employee'<\/span>)    <span class=\"hljs-comment\"># __init__ method is called here and initializes the object name with \"Mr Employee\"<\/span>\r\nemp.introduce()<\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"why-is-finalize-method-used\" class=\"ibpage-article-header\">\n<h5><strong>3. Why is finalize used?<\/strong><\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>Finalize method is used for freeing up the unmanaged resources and clean up before the garbage collection method is invoked. This helps in performing memory management tasks.<\/article>\n<\/section>\n<section id=\"difference-between-new-and-override\" class=\"ibpage-article-header\">\n<h5><strong>4. Differentiate between new and override modifiers.<\/strong><\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>The new modifier is used to instruct the compiler to use the new implementation and not the base class function. The Override modifier is useful for overriding a base class function inside the child class.<\/article>\n<\/section>\n<section id=\"how-to-create-empty-class-in-python\" class=\"ibpage-article-header\">\n<h5><strong>5. How is an empty class created in python?<\/strong><\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>An empty class does not have any members defined in it. It is created by using the pass keyword (the pass command does nothing in python). We can create objects for this class outside the class.<br \/>\nFor example-<\/p>\n<pre><code class=\"language-python hljs\"><span class=\"hljs-class\"><span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title\">EmptyClassDemo<\/span>:<\/span>\r\n   <span class=\"hljs-keyword\">pass<\/span>\r\nobj=EmptyClassDemo()\r\nobj.name=<span class=\"hljs-string\">\"Entri App\"<\/span>\r\n<span class=\"hljs-built_in\">print<\/span>(<span class=\"hljs-string\">\"Name created= \"<\/span>,obj.name)<\/code><\/pre>\n<p><strong>Output:<\/strong><br \/>\nName created = Entri App<\/p>\n<h3><strong>Python Pandas Interview Questions<\/strong><\/h3>\n<\/article>\n<\/section>\n<section id=\"how-to-add-new-column-to-pandas-dataframe\" class=\"ibpage-article-header\">\n<h5>1. How to add new column to pandas dataframe?<\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>A new column can be added to a pandas dataframe as follows:<\/p>\n<pre><code class=\"language-python hljs\"><span class=\"hljs-keyword\">import<\/span> pandas <span class=\"hljs-keyword\">as<\/span> pd      \r\ndata_info = {<span class=\"hljs-string\">'first'<\/span> : pd.Series([<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>], index=[<span class=\"hljs-string\">'a'<\/span>, <span class=\"hljs-string\">'b'<\/span>, <span class=\"hljs-string\">'c'<\/span>]),    \r\n       <span class=\"hljs-string\">'second'<\/span> : pd.Series([<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">4<\/span>], index=[<span class=\"hljs-string\">'a'<\/span>, <span class=\"hljs-string\">'b'<\/span>, <span class=\"hljs-string\">'c'<\/span>, <span class=\"hljs-string\">'d'<\/span>])}    \r\n  \r\ndf = pd.DataFrame(data_info)    \r\n<span class=\"hljs-comment\">#To add new column third<\/span>\r\ndf[<span class=\"hljs-string\">'third'<\/span>]=pd.Series([<span class=\"hljs-number\">10<\/span>,<span class=\"hljs-number\">20<\/span>,<span class=\"hljs-number\">30<\/span>],index=[<span class=\"hljs-string\">'a'<\/span>,<span class=\"hljs-string\">'b'<\/span>,<span class=\"hljs-string\">'c'<\/span>])    \r\n<span class=\"hljs-built_in\">print<\/span> (df)    \r\n<span class=\"hljs-comment\">#To add new column fourth<\/span>\r\ndf[<span class=\"hljs-string\">'fourth'<\/span>]=df[<span class=\"hljs-string\">'first'<\/span>]+info[<span class=\"hljs-string\">'third'<\/span>]    \r\n<span class=\"hljs-built_in\">print<\/span> (df)    <\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"reindexing-in-pandas-dataframe\" class=\"ibpage-article-header\">\n<h5>2. What do you understand by reindexing in pandas?<\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>Reindexing is the process of conforming a dataframe to a new index with optional filling logic. If the values are missing in the previous index, then NaN\/NA is placed in the location. A new object is returned unless a new index is produced that is equivalent to the current one. The copy value is set to False. This is also used for changing the index of rows and columns in the dataframe.<\/article>\n<\/section>\n<section id=\"identifying-and-dealing-with-missing-values-in-a-dataframe\" class=\"ibpage-article-header\">\n<h5>3. How will you identify and deal with missing values in a dataframe?<\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>We can identify if a dataframe has missing values by using the isnull() and isna() methods.<\/p>\n<pre><code class=\"language-python hljs\">missing_data_count=df.isnull().<span class=\"hljs-built_in\">sum<\/span>()<\/code><\/pre>\n<p>We can handle missing values by either replacing the values in the column with 0 as follows:<\/p>\n<pre><code class=\"language-python hljs\">df[\u2018column_name\u2019].fillna(<span class=\"hljs-number\">0<\/span>)<\/code><\/pre>\n<p>Or by replacing it with the mean value of the column<\/p>\n<pre><code class=\"language-python hljs\">df[\u2018column_name\u2019] = df[\u2018column_name\u2019].fillna((df[\u2018column_name\u2019].mean()))<\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"create-series-from-dictionary-in-pandas\" class=\"ibpage-article-header\">\n<h5>4. Can you create a series from the dictionary object in pandas?<\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>One dimensional array capable of storing different data types is called a series. We can create pandas series from a dictionary object as shown below:<\/p>\n<pre><code class=\"language-python hljs\"><span class=\"hljs-keyword\">import<\/span> pandas <span class=\"hljs-keyword\">as<\/span> pd    \r\ndict_info = {<span class=\"hljs-string\">'key1'<\/span> : <span class=\"hljs-number\">2.0<\/span>, <span class=\"hljs-string\">'key2'<\/span> : <span class=\"hljs-number\">3.1<\/span>, <span class=\"hljs-string\">'key3'<\/span> : <span class=\"hljs-number\">2.2<\/span>}  \r\nseries_obj = pd.Series(dict_info)    \r\n<span class=\"hljs-built_in\">print<\/span> (series_obj)    \r\nOutput:\r\nx     <span class=\"hljs-number\">2.0<\/span>\r\ny     <span class=\"hljs-number\">3.1<\/span>\r\nz     <span class=\"hljs-number\">2.2<\/span>\r\ndtype: float64<\/code><\/pre>\n<p>If an index is not specified in the input method, then the keys of the dictionaries are sorted in ascending order for constructing the index. In case the index is passed, then values of the index label will be extracted from the dictionary.<\/p>\n<\/article>\n<\/section>\n<section id=\"merge-pandas-dataframes\" class=\"ibpage-article-header\">\n<h5>5. How will you combine different pandas dataframes?<\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>The dataframes can be combines using the below approaches:<\/p>\n<ul>\n<li><strong>append() method<\/strong>: This is used to stack the dataframes horizontally. Syntax:<\/li>\n<\/ul>\n<pre><code class=\"language-python hljs\">df1.append(df2)<\/code><\/pre>\n<ul>\n<li><strong>concat() method:\u00a0<\/strong>This is used to stack dataframes vertically. This is best used when the dataframes have the same columns and similar fields. Syntax:<\/li>\n<\/ul>\n<pre><code class=\"language-python hljs\">pd.concat([df1, df2]) <\/code><\/pre>\n<ul>\n<li><strong>join() method:\u00a0<\/strong>This is used for extracting data from various dataframes having one or more common columns.<\/li>\n<\/ul>\n<pre><code class=\"language-python hljs\">df1.join(df2)<\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"define-pandas-dataframe\" class=\"ibpage-article-header\">\n<h5>6. Define pandas dataframe.<\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>A dataframe is a 2D mutable and tabular structure for representing data labelled with axes &#8211; rows and columns.<br \/>\n<strong>The syntax for creating dataframe:<\/strong><\/article>\n<\/section>\n<section id=\"define-pandas-dataframe\" class=\"ibpage-article-header\">\n<article class=\"ibpage-article\">\n<pre><code class=\"language-python hljs\"><span class=\"hljs-keyword\">import<\/span> pandas <span class=\"hljs-keyword\">as<\/span> pd\r\ndataframe = pd.DataFrame( data, index, columns, dtype)<\/code><\/pre>\n<\/article>\n<\/section>\n<h3><strong>Python Libraries Interview Questions<\/strong><\/h3>\n<section id=\"difference-between-deep-and-shallow-copies\" class=\"ibpage-article-header\">\n<h5><strong>1. Differentiate between deep and shallow copies.<\/strong><\/h5>\n<p><strong>Answer:<\/strong><\/p>\n<article class=\"ibpage-article\">\n<ul>\n<li>Shallow copy does the task of creating new objects storing references of original elements. This does not undergo recursion to create copies of nested objects. It just copies the reference details of nested objects.<\/li>\n<li>Deep copy creates an independent and new copy of an object and even copies all the nested objects of the original element recursively.<\/li>\n<\/ul>\n<\/article>\n<\/section>\n<section id=\"python-main-function-how-do-you-invoke-it\" class=\"ibpage-article-header\">\n<h5><strong>2. What is main function in python? How do you invoke it?<\/strong><\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>In the world of programming languages, the main is considered as an entry point of execution for a program. But in python, it is known that the interpreter serially interprets the file line-by-line. This means that python does not provide\u00a0<code>main()<\/code>\u00a0function explicitly. But this doesn&#8217;t mean that we cannot simulate the execution of main. This can be done by defining user-defined\u00a0<code>main()<\/code>\u00a0function and by using the\u00a0<code>__name__<\/code>\u00a0property of python file. This\u00a0<code>__name__<\/code>\u00a0variable is a special built-in variable that points to the name of the current module. This can be done as shown below:<\/p>\n<pre><code class=\"language-python hljs\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">main<\/span>():<\/span>\r\n   <span class=\"hljs-built_in\">print<\/span>(<span class=\"hljs-string\">\"Hello Entri App!\"<\/span>)\r\n<span class=\"hljs-keyword\">if<\/span> __name__==<span class=\"hljs-string\">\"__main__\"<\/span>:\r\n   main()<\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"tools-for-identifying-bugs-and-performing-static-analysis-in-python\" class=\"ibpage-article-header\">\n<h5><strong>3. Are there any tools for identifying bugs and performing static analysis in python?<\/strong><\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>Yes, there are tools like PyChecker and Pylint which are used as static analysis and linting tools respectively. PyChecker helps find bugs in python source code files and raises alerts for code issues and their complexity. Pylint checks for the module\u2019s coding standards and supports different plugins to enable custom features to meet this requirement.<\/article>\n<\/section>\n<section id=\"python-pip\" class=\"ibpage-article-header\">\n<h5><strong>4. Define PIP.<\/strong><\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>PIP stands for Python Installer Package. As the name indicates, it is used for installing different python modules. It is a command-line tool providing a seamless interface for installing different python modules. It searches over the internet for the package and installs them into the working directory without the need for any interaction with the user. The syntax for this is:<\/p>\n<pre><code class=\"language-python hljs\">pip install &lt;package_name&gt;<\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"define-pythonpath\" class=\"ibpage-article-header\">\n<h5><strong>5. Define PYTHONPATH.<\/strong><\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>It is an environment variable used for incorporating additional directories during the import of a module or a package. PYTHONPATH is used for checking if the imported packages or modules are available in the existing directories. Not just that, the interpreter uses this environment variable to identify which module needs to be loaded.<\/article>\n<\/section>\n<section id=\"global-interpreter-lock\" class=\"ibpage-article-header\">\n<h5><strong>6. Define GIL.<\/strong><\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>GIL stands for Global Interpreter Lock. This is a mutex used for limiting access to python objects and aids in effective thread synchronization by avoiding deadlocks. GIL helps in achieving multitasking (and not parallel computing). The following diagram represents how GIL works.<\/article>\n<\/section>\n<h3><strong>Numpy Interview Questions<\/strong><\/h3>\n<section id=\"reverse-the-numpy-array-using-one-line-of-code\" class=\"ibpage-article-header\">\n<h5><strong>1. How will you reverse the numpy array using one line of code?<\/strong><\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>This can be done as shown in the following:<\/p>\n<pre><code class=\"language-python hljs\">reversed_array = arr[::-<span class=\"hljs-number\">1<\/span>]<\/code><\/pre>\n<p>where\u00a0<strong>arr<\/strong>\u00a0= original given array, reverse_array is the resultant after reversing all elements in the input.<\/p>\n<\/article>\n<\/section>\n<section id=\"how-will-you-find-the-nearest-value-in-a-given-numpy-array\" class=\"ibpage-article-header\">\n<h5><strong>2. How will you find the nearest value in a given numpy array?<\/strong><\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>We can use the argmin() method of numpy as shown below:<\/p>\n<pre><code class=\"language-python hljs\"><span class=\"hljs-keyword\">import<\/span> numpy <span class=\"hljs-keyword\">as<\/span> np\r\n<span class=\"hljs-function\"><span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title\">find_nearest_value<\/span>(<span class=\"hljs-params\">arr, value<\/span>):<\/span>\r\n   arr = np.asarray(arr)\r\n   idx = (np.<span class=\"hljs-built_in\">abs<\/span>(arr - value)).argmin()\r\n   <span class=\"hljs-keyword\">return<\/span> arr[idx]\r\n<span class=\"hljs-comment\">#Driver code<\/span>\r\narr = np.array([ <span class=\"hljs-number\">0.21169<\/span>,  <span class=\"hljs-number\">0.61391<\/span>, <span class=\"hljs-number\">0.6341<\/span>, <span class=\"hljs-number\">0.0131<\/span>, <span class=\"hljs-number\">0.16541<\/span>,  <span class=\"hljs-number\">0.5645<\/span>,  <span class=\"hljs-number\">0.5742<\/span>])\r\nvalue = <span class=\"hljs-number\">0.52<\/span>\r\n<span class=\"hljs-built_in\">print<\/span>(find_nearest_value(arr, value)) <span class=\"hljs-comment\"># Prints 0.5645<\/span><\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"how-will-you-sort-the-array-based-on-the-nth-column\" class=\"ibpage-article-header\">\n<h5><strong>3. How will you sort the array based on the Nth column?<\/strong><\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>For example, consider an array arr.<\/p>\n<pre><code class=\"language-python hljs\">arr = np.array([[<span class=\"hljs-number\">8<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">2<\/span>],\r\n          [<span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">6<\/span>, <span class=\"hljs-number\">5<\/span>],\r\n          [<span class=\"hljs-number\">6<\/span>, <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">4<\/span>]])<\/code><\/pre>\n<p>Let us try to sort the rows by the 2nd column so that we get:<\/p>\n<pre><code class=\"language-python hljs\">[[<span class=\"hljs-number\">6<\/span>, <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">4<\/span>],\r\n[<span class=\"hljs-number\">8<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">2<\/span>],\r\n[<span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">6<\/span>, <span class=\"hljs-number\">5<\/span>]]<\/code><\/pre>\n<p>We can do this by using the sort() method in numpy as:<\/p>\n<pre><code class=\"language-python hljs\"><span class=\"hljs-keyword\">import<\/span> numpy <span class=\"hljs-keyword\">as<\/span> np\r\narr = np.array([[<span class=\"hljs-number\">8<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">2<\/span>],\r\n          [<span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">6<\/span>, <span class=\"hljs-number\">5<\/span>],\r\n          [<span class=\"hljs-number\">6<\/span>, <span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">4<\/span>]])\r\n<span class=\"hljs-comment\">#sort the array using np.sort<\/span>\r\narr = np.sort(arr.view(<span class=\"hljs-string\">'i8,i8,i8'<\/span>),\r\n       order=[<span class=\"hljs-string\">'f1'<\/span>],\r\n       axis=<span class=\"hljs-number\">0<\/span>).view(np.<span class=\"hljs-built_in\">int<\/span>)<\/code><\/pre>\n<p>We can also perform sorting and that too inplace sorting by doing:<\/p>\n<pre><code class=\"language-python hljs\">arr.view(<span class=\"hljs-string\">'i8,i8,i8'<\/span>).sort(order=[<span class=\"hljs-string\">'f1'<\/span>], axis=<span class=\"hljs-number\">0<\/span>)<\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"how-will-you-read-csv-data-into-an-array-in-numpy\" class=\"ibpage-article-header\">\n<h5><strong>4. How will you read CSV data into an array in NumPy?<\/strong><\/h5>\n<article class=\"ibpage-article\"><strong>Answer: <\/strong>This can be achieved by using the genfromtxt() method by setting the delimiter as a comma.<\/p>\n<pre><code class=\"language-python hljs\"><span class=\"hljs-keyword\">from<\/span> numpy <span class=\"hljs-keyword\">import<\/span> genfromtxt\r\ncsv_data = genfromtxt(<span class=\"hljs-string\">'sample_file.csv'<\/span>, delimiter=<span class=\"hljs-string\">','<\/span>)<\/code><\/pre>\n<\/article>\n<\/section>\n<section id=\"loading-a-text-file-data-using-numpy\" class=\"ibpage-article-header\">\n<h5><strong>5. How are NumPy arrays advantageous over python lists?<\/strong><\/h5>\n<p><strong>Answer:<\/strong><\/p>\n<article class=\"ibpage-article\">\n<ul>\n<li>The list data structure of python is very highly efficient and is capable of performing various functions. But, they have severe limitations when it comes to the computation of vectorized operations which deals with element-wise multiplication and addition. The python lists also require the information regarding the type of every element which results in overhead as type dispatching code gets executes every time any operation is performed on any element. This is where the NumPy arrays come into the picture as all the limitations of python lists are handled in NumPy arrays.<\/li>\n<li>Additionally, as the size of the NumPy arrays increases, NumPy becomes around 30x times faster than the Python List. This is because the Numpy arrays are densely packed in the memory due to their homogenous nature. This ensures the memory free up is also faster.<\/li>\n<\/ul>\n<p style=\"text-align: center\"><strong><a class=\"in-cell-link\" href=\"https:\/\/entri.app\/course\/python-programming-course\/?utm_source=python-programming&amp;utm_medium=blog_referral&amp;utm_campaign=morgan-stanley-python-interview-questions\" target=\"_blank\" rel=\"noopener\">Get hands-on with our python course \u2013 sign up for a free demo!<\/a><\/strong><\/p>\n<\/article>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>As the demand for skilled Python developers continues to grow, Ernst &amp; Young (EY), one of the &#8220;Big Four&#8221; accounting firms, seeks professionals who can not only write efficient code but also solve complex business problems using Python. EY interviews often cover a wide range of topics, from core Python concepts to advanced problem-solving techniques. [&hellip;]<\/p>\n","protected":false},"author":100,"featured_media":25596200,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[802,1888],"tags":[],"class_list":["post-25596196","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles","category-python-programming"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>EY Python Interview Questions - Entri Blog<\/title>\n<meta name=\"description\" content=\"Prepare for your EY Python interview with these top questions and answers, covering Python programming, object-oriented concepts etc.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"EY Python Interview Questions - Entri Blog\" \/>\n<meta property=\"og:description\" content=\"Prepare for your EY Python interview with these top questions and answers, covering Python programming, object-oriented concepts etc.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/\" \/>\n<meta property=\"og:site_name\" content=\"Entri Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/entri.me\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-21T18:18:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-21T18:30:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/11\/EY-Python-Interview-Questions.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"820\" \/>\n\t<meta property=\"og:image:height\" content=\"615\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Sabira Ulfath\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@entri_app\" \/>\n<meta name=\"twitter:site\" content=\"@entri_app\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sabira Ulfath\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"21 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/\"},\"author\":{\"name\":\"Sabira Ulfath\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/c79ea15b3ee5dab855ebea929c9a6046\"},\"headline\":\"EY Python Interview Questions\",\"datePublished\":\"2024-11-21T18:18:48+00:00\",\"dateModified\":\"2024-11-21T18:30:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/\"},\"wordCount\":3761,\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/11\/EY-Python-Interview-Questions.webp\",\"articleSection\":[\"Articles\",\"Python Programming\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/\",\"url\":\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/\",\"name\":\"EY Python Interview Questions - Entri Blog\",\"isPartOf\":{\"@id\":\"https:\/\/entri.app\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/11\/EY-Python-Interview-Questions.webp\",\"datePublished\":\"2024-11-21T18:18:48+00:00\",\"dateModified\":\"2024-11-21T18:30:23+00:00\",\"description\":\"Prepare for your EY Python interview with these top questions and answers, covering Python programming, object-oriented concepts etc.\",\"breadcrumb\":{\"@id\":\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#primaryimage\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/11\/EY-Python-Interview-Questions.webp\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/11\/EY-Python-Interview-Questions.webp\",\"width\":820,\"height\":615,\"caption\":\"EY Python Interview Questions\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/entri.app\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python Programming\",\"item\":\"https:\/\/entri.app\/blog\/category\/python-programming\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"EY Python Interview Questions\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/entri.app\/blog\/#website\",\"url\":\"https:\/\/entri.app\/blog\/\",\"name\":\"Entri Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/entri.app\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/entri.app\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/entri.app\/blog\/#organization\",\"name\":\"Entri App\",\"url\":\"https:\/\/entri.app\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"contentUrl\":\"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png\",\"width\":989,\"height\":446,\"caption\":\"Entri App\"},\"image\":{\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/entri.me\/\",\"https:\/\/x.com\/entri_app\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/entri.app\/blog\/#\/schema\/person\/c79ea15b3ee5dab855ebea929c9a6046\",\"name\":\"Sabira Ulfath\",\"url\":\"https:\/\/entri.app\/blog\/author\/sabira\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"EY Python Interview Questions - Entri Blog","description":"Prepare for your EY Python interview with these top questions and answers, covering Python programming, object-oriented concepts etc.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/entri.app\/blog\/ey-python-interview-questions\/","og_locale":"en_US","og_type":"article","og_title":"EY Python Interview Questions - Entri Blog","og_description":"Prepare for your EY Python interview with these top questions and answers, covering Python programming, object-oriented concepts etc.","og_url":"https:\/\/entri.app\/blog\/ey-python-interview-questions\/","og_site_name":"Entri Blog","article_publisher":"https:\/\/www.facebook.com\/entri.me\/","article_published_time":"2024-11-21T18:18:48+00:00","article_modified_time":"2024-11-21T18:30:23+00:00","og_image":[{"width":820,"height":615,"url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/11\/EY-Python-Interview-Questions.webp","type":"image\/webp"}],"author":"Sabira Ulfath","twitter_card":"summary_large_image","twitter_creator":"@entri_app","twitter_site":"@entri_app","twitter_misc":{"Written by":"Sabira Ulfath","Est. reading time":"21 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#article","isPartOf":{"@id":"https:\/\/entri.app\/blog\/ey-python-interview-questions\/"},"author":{"name":"Sabira Ulfath","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/c79ea15b3ee5dab855ebea929c9a6046"},"headline":"EY Python Interview Questions","datePublished":"2024-11-21T18:18:48+00:00","dateModified":"2024-11-21T18:30:23+00:00","mainEntityOfPage":{"@id":"https:\/\/entri.app\/blog\/ey-python-interview-questions\/"},"wordCount":3761,"publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"image":{"@id":"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/11\/EY-Python-Interview-Questions.webp","articleSection":["Articles","Python Programming"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/entri.app\/blog\/ey-python-interview-questions\/","url":"https:\/\/entri.app\/blog\/ey-python-interview-questions\/","name":"EY Python Interview Questions - Entri Blog","isPartOf":{"@id":"https:\/\/entri.app\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#primaryimage"},"image":{"@id":"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#primaryimage"},"thumbnailUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/11\/EY-Python-Interview-Questions.webp","datePublished":"2024-11-21T18:18:48+00:00","dateModified":"2024-11-21T18:30:23+00:00","description":"Prepare for your EY Python interview with these top questions and answers, covering Python programming, object-oriented concepts etc.","breadcrumb":{"@id":"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/entri.app\/blog\/ey-python-interview-questions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#primaryimage","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/11\/EY-Python-Interview-Questions.webp","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2024\/11\/EY-Python-Interview-Questions.webp","width":820,"height":615,"caption":"EY Python Interview Questions"},{"@type":"BreadcrumbList","@id":"https:\/\/entri.app\/blog\/ey-python-interview-questions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/entri.app\/blog\/"},{"@type":"ListItem","position":2,"name":"Python Programming","item":"https:\/\/entri.app\/blog\/category\/python-programming\/"},{"@type":"ListItem","position":3,"name":"EY Python Interview Questions"}]},{"@type":"WebSite","@id":"https:\/\/entri.app\/blog\/#website","url":"https:\/\/entri.app\/blog\/","name":"Entri Blog","description":"","publisher":{"@id":"https:\/\/entri.app\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/entri.app\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/entri.app\/blog\/#organization","name":"Entri App","url":"https:\/\/entri.app\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","contentUrl":"https:\/\/entri.app\/blog\/wp-content\/uploads\/2019\/10\/Entri-Logo-1.png","width":989,"height":446,"caption":"Entri App"},"image":{"@id":"https:\/\/entri.app\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/entri.me\/","https:\/\/x.com\/entri_app"]},{"@type":"Person","@id":"https:\/\/entri.app\/blog\/#\/schema\/person\/c79ea15b3ee5dab855ebea929c9a6046","name":"Sabira Ulfath","url":"https:\/\/entri.app\/blog\/author\/sabira\/"}]}},"_links":{"self":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25596196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/users\/100"}],"replies":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/comments?post=25596196"}],"version-history":[{"count":5,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25596196\/revisions"}],"predecessor-version":[{"id":25596242,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/posts\/25596196\/revisions\/25596242"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media\/25596200"}],"wp:attachment":[{"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/media?parent=25596196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/categories?post=25596196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/entri.app\/blog\/wp-json\/wp\/v2\/tags?post=25596196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}