Giter Club home page Giter Club logo

python-interview-questions's Introduction

Python Interview Questions

Table of Contents

No. Questions
Introduction
1 What does the Zen of Python mean?
2 What does PEP 8 mean?
Core Python
3 First Class functions in Python
4 Python Anonymous/Lambda Function
5 Decorators in Python
6 Generators in Python
7 Difference between == and is operator in Python
8 Python Shallow Copy and Deep Copy?
10 Context manager in python
Python OOP
Others
Monkey Patching in Python (Dynamic Behavior)

Introduction

  1. What does the Zen of Python mean?

    The Zen of Python is a collection of 19 "guiding principles" for writing computer programs that influence the design of the Python programming language. Software engineer Tim Peters wrote this set of principles and posted it on the Python mailing list in 1999. More details..

    ⬆ Back to Top

  2. What does PEP 8 mean?

    PEP 8 is a document that provides guidelines and best practices on how to write Python code. The primary focus of PEP 8 is to improve the readability and consistency of Python code. More details..

    ⬆ Back to Top

Core Python

  1. First Class functions in Python?

    First class objects in a language are handled uniformly throughout. They may be stored in data structures, passed as arguments, or used in control structures. A programming language is said to support first-class functions if it treats functions as first-class objects. Python supports the concept of First Class functions.

    Properties of first class functions:

    • A function is an instance of the Object type.
    • You can store the function in a variable.
    • You can pass the function as a parameter to another function.
    • You can return the function from a function.
    • You can store them in data structures such as hash tables, lists…

    More details..

    ⬆ Back to Top

  2. Python Anonymous/Lambda Function?

    In Python, an anonymous function is a function that is defined without a name. While normal functions are defined using the def keyword in Python, anonymous functions are defined using the lambda keyword. Hence, anonymous functions are also called lambda functions. More details..

    Note: Lambda functions can have any number of arguments but only one expression.

    ⬆ Back to Top

  3. Decorators in Python?

    A decorator is a design pattern in Python that allows a user to add new functionality to an existing object without modifying its structure. Decorators are usually called before the definition of a function you want to decorate.

    More details (Datacamp)... | More details (GeeksforGeeks)...

    ⬆ Back to Top

  4. Generators in Python?

    Python generator functions are a special kind of function that return a lazy iterator. These are objects that you can loop over like a list. However, unlike lists, lazy iterators do not store their contents in memory. More details...

    ⬆ Back to Top

  5. Difference between == and is operator in Python?

    The Equality operator (==) compares the values of both the operands and checks for value equality. Whereas the ‘is’ operator checks whether both the operands refer to the same object or not. More details...

    ⬆ Back to Top

  6. Python Shallow Copy and Deep Copy?

    Deep copy is a process in which the copying process occurs recursively. It means first constructing a new collection object and then recursively populating it with copies of the child objects found in the original. In case of deep copy, a copy of object is copied in other object. It means that any changes made to a copy of object do not reflect in the original object. In python, this is implemented using “deepcopy()” function.

    A shallow copy means constructing a new collection object and then populating it with references to the child objects found in the original. The copying process does not recurse and therefore won’t create copies of the child objects themselves. In case of shallow copy, a reference of object is copied in other object. It means that any changes made to a copy of object do reflect in the original object. In python, this is implemented using “copy()” function.

    More details...

    ⬆ Back to Top

  7. Monkey Patching in Python (Dynamic Behavior)

    In Python, the term monkey patch refers to dynamic (or run-time) modifications of a class or module. In Python, we can actually change the behavior of code at run-time.

    More details...

    ⬆ Back to Top

  8. Context manager in python

    Context manager is used to set up and tear down resources, such as file handling or database connections, in a clean and controlled manner.

    More details...

    ⬆ Back to Top

python-interview-questions's People

Contributors

akashmallik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.