Python Concepts Explained

Concepts of python organized in a Q&A format.

Photo by Chris Ried on Unsplash

1. Applications for debugging?

pychecker. pylint

2. Difference between Lists and Tuples?

Lists are mutable while Tuples aren’t

3. How does python manage its memory?

Python memory is managed by Python private heap space. All Python objects and data structures are located in a private heap. The programmer does not have an access to this private heap and interpreter takes care of this Python private heap.

The allocation of Python heap space for Python objects is done by Python memory manager. The core API gives access to some tools for the programmer to code.

Python also have an inbuilt garbage collector, which recycle all the unused memory and frees the memory and makes it available to the heap space.

4. Difference between Def and Lambda?

Def has multiple expressions, Lambda has a single function.
Def creates a function and names it to call back later, but Lambda configures and returns the function object.

5. What kinds of Built-in types are there?

There are mutable and Immutable types of Pythons built in types Mutable built-in types

  • List
  • Sets
  • Dictionaries

Immutable built-in types

  • Strings
  • Tuples
  • Numbers

6. What is Slicing?

A mechanism to select a range of items from sequence types like list, tuple, strings etc. is known as slicing.

7. What is a dynamically typed language?

A language where the type of a variable is checked during run-time.

8. When was python created?

In 1991

9. What is PEP 8?

PEP 8 is defined as a document that helps us to provide the guidelines on how to write the Python code. It was written by Guido van Rossum, Barry Warsaw and Nick Coghlan in 2001.

It stands for Python Enhancement Proposal, and its major task is to improve the readability and consistency of Python code.

10. What are Python literals?

Literals can be defined as a data which is given in a variable or constant. Python supports the following literals:

  • Numeric literals
  • String literals
  • Boolean literals

11. What is __init__ in python?

__init__ is one of the reserved methods in Python. In object oriented programming, it is known as a constructor. The __init__ method can be called when an object is created from the class, and access is required to initialize the attributes of the class.

12. What is an object oriented programming language?

Everything that you create in the Python environment is termed as being object.

13. What is the Python decorator?

Decorators are very powerful and a useful tool in Python that allows the programmers to modify the behaviour of any class or function. It allows us to wrap another function to extend the behaviour of the wrapped function, without permanently modifying it. A function is a block of code that performs a specific task whereas a decorator is a function that modifies other functions.

14. What is a dictonary?

The Python dictionary is a built-in data type. It defines a one-to-one relationship between keys and values. Dictionaries contain a pair of keys and their corresponding values. It stores elements in key and value pairs. The keys are unique whereas values can be duplicate. The key accesses the dictionary elements.

15. What is a negative index in Python?

Python sequences are accessible using an index in positive and negative numbers. For example, 0 is the first positive index, 1 is the second positive index and so on. For negative indexes -1 is the last negative index, -2 is the second last negative index and so on.

Index traverses from left to right and increases by one until end of the list.

Negative index traverse from right to left and iterate one by one till the start of the list. A negative index is used to traverse the elements into reverse order.



Product Manager and Data Analyst

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store