• Python Reduce Function

    Python Reduce Function

    Python Reduce Function Table Of Contents: What Is Python Reducer? How To Implement Python Reducer? Examples Of Python Reducer? (1) What Is Python Reducer? If you want to apply some aggregate functions to an iterable like, adding, subtracting, multiplying, or concatenating all the values, then you can use the Python reduce() function. Python has an inbuilt reduce() function which you can import from “functools” module. (2) How To Implement Python Reducer? Syntax: import functools functools.reduce(function, iterable) Arguments: function – This function will be applied to all the elements in an iterable in a cumulative manner to compute the result. iterable

    Read More

  • Python Filter Function

    Python Filter Function

    Python Filter Function Table Of Contents: What Is A Filter Function? Syntax Of Filter Function. Examples Of Filter Function. (1) What Is A Filter Function? Python filter( ) method is an inbuilt method, which is used to filter out the required values from an iterable like(a list, tuple, set, or dictionary). The filter( ) method will return an iterator that you can easily convert iterators to sequences like lists, tuples, strings etc. (2) Syntax Of Filter Function. filter(function, iterable) Filter Parameters: function: A Function to be run for each item in the iterable iterable: The iterable to be filtered. Filter

    Read More

  • Python Map Functions

    Python Map Functions

    Python Map Functions Table Of Contents: What Is Map Function? Syntax Of Map Function. Examples Of Map Function. (1) What Is A Map Function? The map( ) function is an in-built python function, which is used to apply a given function to each item of an iterable (list, tuple etc.) The map( ) function will return an iterator (list, tuple etc) as an output. (2) Syntax Of Map Function? map(function, iterable) The map( ) Parameters: The map( ) function takes two parameters:(1) function – a function that performs some action on each element of an iterable(2) iterable – an iterable

    Read More

  • Python Extended Keyword Arguments(*args, **kwargs

    Python Extended Keyword Arguments(*args, **kwargs

    Python Extended Keyword Arguments(*args, **kwargs) Table Of Contents: What Are Extended Keyword Arguments? What Is Python *args? What Is Python **kwargs? Using Both *args and **kwargs. (1) What Is Extended Keyword Arguments? Arguments are the values passed to the function, for further processing. Most of the time you will know how many arguments a function can take. But, sometimes the argument counts can vary, and then your function will fail to accommodate those arguments. To handle this issue we have ‘Extended Keyword Arguments‘. Without Extended Keyword Arguments. def student(name,rollno,subject): print(‘Student Name:’,name) print(‘Student RollNo:’,rollno) print(‘Student Subject:’,subject) student(‘Abhispa’,’143′,’Math’,99) Output: TypeError Traceback (most

    Read More

  • Python Comprehensions

    Python Comprehensions

    Python Comprehensions Table Of Contents: What Is Comprehension? List Comprehensions Dictionary Comprehensions Set Comprehensions Generator Comprehensions (1) What Is Comprehension? Comprehension is the process of reducing the code length and being able to write it in a single statement. Using comprehension you can use filtering, mapping, and apply conditional logic to the members of a sequence (such as lists, set, dictionary etc.) in a single line. Comprehension allows us to filter the elements of the sequence and apply some conditional logic to an existing sequence, and it will return a new sequence. Without Comprehensions: numbers = [1,2,3,4,5,6,7,8,9,10] even_numbers = []

    Read More

  • Python Abstraction

    Python Abstraction

    Python Abstraction Table Of Contents: What Is Abstraction? Need Of Abstraction? Implementing Abstraction In Python. Abstract Base Class. Abstract Class. Abstract Method. Concrete Methods In Abstract Base Class. Abstract Class Instantiation. (1) What Is Abstraction? Abstraction helps us to hide the internal implementation of the function from the users. Hence the user can use that function without knowing the internal implementation. User is familiar with that “what function does” but they don’t know “how it does.” (2) Need Of Abstraction? Abstraction provides a programmer to hide all the irrelevant data/processes of an application in order to reduce complexity and increase

    Read More

  • Python Encapsulation

    Python Encapsulation

    Python Encapsulation Table Of Contents: What Is Encapsulation? Why We Need Encapsulation? How To Implement Encapsulation? Access Modifiers In Python. Public Members. Private Members. Protected Members. (1) What Is Encapsulation? When you take lunch to school, you generally put it inside the lunch box to protect it from the outside environment. Like this in the programming world, to protect your sensitive information you need encapsulation. Encapsulation allows us to protect our properties and methods of the class from the other classes, which you have not written by yourself. When another method of the class is trying to access your members,

    Read More