Python | Detecting the number of local variables declared in a function

To calculate the number of local variables in a particular function we have a dedicated built-in function. Let us take a look at it Output:…

Continue Reading

Python | Making a chain of function decorators (bold italic underline etc)

Output: Explanation: Here in this program, we defined three functions and in each function, we added the tags for bold, italic and underline respectively. A…

Continue Reading

Python | Access function inside a function

Let us take a look at how this can be done in Python. Example 1: Explanation: We define inner functions—also referred to as nested functions—within…

Continue Reading

Python | Create a function with a pass statement

Today, in this article we will be learning about a Python Program to create a function with a pass statement. Before moving on to the…

Continue Reading

Python | Function to calculate the square root of a number

Let us look at the methods we have to calculate the square root of a number. Here we will use functions. In the first method,…

Continue Reading

Python | A function that calculates the power of a number

Let us take a look at how to code for this program. We have some built-in functions and other than that we will also take…

Continue Reading

Python | A function that accepts 2 integers and adds them and returns their sum

Here we will go through two methods that are there to solve this problem. Let us take a look at each of them. Method 1:…

Continue Reading

Python | Function that takes a list of integers and returns the last integer

Let us now take a look at the different ways in which we can solve this problem. Here we will be using the concept of…

Continue Reading

Python | Return multiple values from a function

Explanation: Once we defined the function and if we want to return multiple values then we simply use the return keyword along with the values…

Continue Reading

Python function that takes a list and returns a new list with unique elements of the first list

Let us get our hands on the Python list with the more amazing problem to solve. Method 1: Using a new list and “not in”…

Continue Reading

Python | Generate a random number in the range of 1 to 10 using the function

Method 1: Using randint() from NumPy Output: Explanation: In this method, we used the numpy library. We defined two variables start and end and passed…

Continue Reading

Python | Check Whether a Given Number is Even or Odd using Recursion

Let us go through all the methods using which we can solve this problem of finding odd and even numbers Method 1: Using the number…

Continue Reading

Python | Print Binary Equivalent of an Integer using Recursion

In order to solve this problem, we only have one method to use. Let us take a look at it. Output: Explanation: Here we used…

Continue Reading

Python | Print Binary Equivalent of a Number without Using Recursion

In the previous article, we saw the same problem but there we solved using recursion. Here we will go through all the methods in which…

Continue Reading

Python | Reverse a string using recursion

Here we are to help you in solving the widely asked question. Lets us take a look at a recursive approach to solve this. Output…

Continue Reading

Python | Find Sum of Digit of a Number Without Recursion

Let us rub our hands on this problem by taking a look at various methods. Method 1: Using for loop Output: Explanation Here we simply…

Continue Reading

Python | Reverse a string without recursion

Let us now see all the methods to solve Python programs to reverse a string without recursion. Method 1: Using the loop Output Explanation We…

Continue Reading

Python | Reverse a list using recursion

Explanation: Here in this approach, we first took the input from the user about the number of elements in the list, and based on that…

Continue Reading

Python | Print Hello world using function

Today in this article, we will talk about how to print “Hello World”, but the only catch is that we will not use the simple…

Continue Reading

Python | Reverse a list without recursion

Let us take a look at how to solve this problem with various different methods. Method 1: Using reduce() of functools method Output: Explanation: At…

Continue Reading