TUTORIAL VIDEO
INTERVIEW QUESTIONS
Python is a high-level, interpreted programming language known for its simplicity and readability, making it easy to learn and maintain. It is versatile, supporting various applications through its extensive libraries and features like object-oriented programming, threading, and automatic memory management. Additionally, Python's open-source nature and strong community support encourage modularity and rapid application development.
Arrays in python can only contain elements of same data types i.e., data type of array should be homogeneous. It is a thin wrapper around C language arrays and consumes far less memory than lists.
Lists in python can contain elements of different data types i.e., data type of lists can be heterogeneous. It has the disadvantage of consuming large memory.
Documentation string or docstring is a multiline string used to document a specific code segment.
The docstring should describe what the function or method does.
Modules, in general, are simply Python files with a .py extension and can have a set of functions, classes, or variables defined and implemented. They can be imported and initialized once using the import statement. If partial functionality is needed, import the requisite classes or functions using from foo import bar.
Packages allow for hierarchial structuring of the module namespace using dot notation. As, modules help avoid clashes between global variable names, in a similar manner, packages help avoid clashes between module names.
Creating a package is easy since it makes use of the system's inherent file structure. So just stuff the modules into a folder and there you have it, the folder name as the package name. Importing a module or its contents from this package requires the package name as prefix to the module name joined by a dot.
The pass keyword represents a null operation in Python. It is generally used for the purpose of filling up empty blocks of code which may execute during runtime but has yet to be written. Without the pass statement in the following code, we may run into some errors during code execution.
__init__ is a contructor method in Python and is automatically called to allocate memory when a new object/instance is created. All classes have a __init__ method associated with them. It helps in distinguishing methods and attributes of a class from local variables.
An iterator is an object that contains a countable number of values.
An iterator is an object that can be iterated upon, meaning that you can traverse through all the values.
Technically, in Python, an iterator is an object which implements the iterator protocol, which consist of the methods __iter__() and __next__().
A variable created inside a function belongs to the local scope of that function, and can only be used inside that function.
A variable created in the main body of the Python code is a global variable and belongs to the global scope. Global variables are available from within any scope, global and local.
Most of us may be surprised to know that python is actually both a compiled and interpreted language., when Python code is executed, it is first compiled into bytecode and then bytecode is interpreted by the Python Virtual Machine (PVM) on the underlying platform (machine + operating system). This hybrid approach allows python to balance ease of development with execution efficiency.
Inheritance allows us to define a class that inherits all the methods and properties from another class.
Parent class is the class being inherited from, also called base class.
Child class is the class that inherits from another class, also called derived class.