Category: Functions
Python : How to unpack list, tuple or dictionary to Function arguments using * & **
In this article we will discuss how to unpack a list, tuple and dictionary to function arguments. Suppose we have a function with 3 parameters i.e. Advertisements def updateStudentDetail(name, phone, address): print(“**********************”) print(“Student Name : “, name) print(“Student phone : “, phone) print(“Student address : “, address) We can call this function and pass three …
Python : How to unpack list, tuple or dictionary to Function arguments using * & **Read More
Python : *args | How to pass multiple arguments to function ?
In this article we will discuss how to define a function in python that can accept variable length arguments. Suppose we have a function to calculate the average of 3 numbers i.e. Advertisements def average(a , b, c): ”’ Function To calculate the average of 3 numbers ”’ return (a+b+c)/3 Now let’s use this function, …
Python : *args | How to pass multiple arguments to function ?Read More
Python : **kwargs | Functions that accept variable length key value pair as arguments
In this article we will discuss how to create functions in Python that can accept variable length arguments in key value pair format. Suppose we want to define a function that will print the provided students details. Details will be in key value pairs, where key represents the property name and value as property’s value. …
Python : **kwargs | Functions that accept variable length key value pair as argumentsRead More
Why do we need Lambda functions in Python ? | Explained with examples.
In this article we will discuss what is a lambda function in python and why they are required. Basically what are the use cases which makes use of lambda function must. What is a lambda function ? Lambda functions are also called Anonymous functions because they don’t have any name. Also they can be assigned …
Why do we need Lambda functions in Python ? | Explained with examples.Read More
Python : How to use if, else & elif in Lambda Functions
In this article we will discuss how to use if , else if and else in a lambda functions in Python. Will also explain how to use conditional lambda function with filter() in python. Using if else in Lambda function Using if else in lambda function is little tricky, the syntax is as follows, lambda …
Python : How to use if, else & elif in Lambda FunctionsRead More
Python : How to use global variables in a function ?
In this article we will discuss difference between local & global variable and will also see ways to access / modify both same name global & local variable inside a function.
Python map() function – Tutorial
In this article, we will discuss how to transform the contents of an iterable sequence using map() function. Also, we will discuss how to use the map() function with lambda functions and how to transform a dictionary using map() too. Table Of Contents Introduction to map() function in Python How does map() function works ? …
Python : filter() function | Tutorial & Examples
In this article we will discuss when & how to use python’s filter() function with lambda filter() function in python Python provides a method to filter out contents from a given sequence that can be a list, string or tuple etc. filter(function, iterable) Arguments: Advertisements An iterable sequence to be filtered. a function that accepts …
Python : max() function explained with examples
In this article we will discuss detailed features of Python’s max() function with examples. Python provides a max() function to find out the largest element from a collection of elements, Advertisements max(iterable, *[, key, default]) max(arg1, arg2, *args[, key]) Arguments: Iterable : An Iterable object like list, tuple etc. arg1, arg2 … : Multiple elements …
Python : min() function Tutorial with examples
In this article we will discuss detailed features of Python’s min() function with examples. Python provides a min() function to find out the smallest element from a collection of elements, Advertisements min(iterable, *[, key, default]) min(arg1, arg2, *args[, key]) Arguments: Iterable : An Iterable object like list, tuple etc. arg1, arg2 … : Multiple elements …