Python is an interpreted programming language. Object-Oriented Programming (OOP) is a paradigm for organizing code for increased reusability and modularity.
A class is a blueprint for creating objects with shared properties and methods. An object is an instance of a class.
Inheritance allows a class to inherit properties and methods from another class. Types of inheritance include single-level, multilevel, hierarchical, multiple, and hybrid inheritance.
Method overriding occurs when a child class defines a method with the same name as a method in the parent class.
The super()
function is used within a child class to call methods from the parent class.
Encapsulation involves hiding the internal details of an object and restricting direct access to its components.
Polymorphism allows methods to behave differently based on the objects they operate on. Method overloading and method overriding are examples of polymorphism.
Decorators modify or extend the behavior of functions without changing their code. They are denoted by the @decorator_name
syntax.
Lambda functions are anonymous functions used for small, single-expression tasks. The map()
function applies a function to each element of an iterable. The filter()
function filters elements from an iterable based on a specified condition.
Exception handling using try
, except
, else
, and finally
blocks allows for graceful error handling in Python.
Modules are files containing Python code that can be imported and used in other Python files. Packages are collections of related modules.
Comprehensions provide a concise way to create sequences like lists, dictionaries, and sets.
Various built-in functions like enumerate()
, zip()
, sorted()
, type()
, etc., perform common tasks in Python.
Control statements like if
, else
, elif
, for
, while
, etc., control the flow of program execution.
Type casting converts one data type to another, e.g., converting an integer to a string.
Sorting algorithms like Bubble Sort, Selection Sort, Insertion Sort, Merge Sort, and Quick Sort organize elements in a specified order.