AmitDiwan has Published 10744 Articles

Python Program to Flatten a List without using Recursion

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 12:34:40

245 Views

When it is required to flatten a list without using recursion technique, the lambda function, ‘sum’ method, ‘map’ method and the ‘isinstance’ method can be used.A list can be used to store heterogeneous values (i.e data of any data type like integer, floating point, strings, and so on).The ‘isinstance’ method ... Read More

Python Program to find the factorial of a number without recursion

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 12:33:40

6K+ Views

When it is required to find the factorial of a number without using recursion, the ‘while’ loop can be used.ExampleBelow is a demonstration for the same − Live Demomy_num = int(input("Enter a number :")) my_factorial = 1 while(my_num>0):    my_factorial = my_factorial*my_num    my_num=my_num-1 print("The factorial of the number is : ... Read More

Python Program to Find the Fibonacci Series without Using Recursion

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 12:32:30

5K+ Views

When it is required to find the Fibonacci series without using recursion technique, the input is taken from the user, and a ‘while’ loop is used to get the numbers in the sequence.ExampleBelow is a demonstration for the same − Live Demofirst_num = int(input("Enter the first number of the fibonacci series... ... Read More

Python Program to Find the Length of a List Using Recursion

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 12:30:03

2K+ Views

When it is required to find the length of a list with the help of recursion technique, a user defined method is used, and simple indexing technique is used.A list can be used to store heterogeneous values (i.e data of any data type like integer, floating point, strings, and so ... Read More

Python Program to Find the Total Sum of a Nested List Using Recursion

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 12:28:23

646 Views

When it is required to find the total sum of a nest list using the recursion technique, a user defined method is used, that takes the list as a parameter.The recursion computes output of small bits of the bigger problem, and combines these bits to give the solution to the ... Read More

Python Program to Flatten a Nested List using Recursion

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 12:26:58

1K+ Views

When it is required to flatten a given nested list using recursion technique, simple indexing, and the ‘isinstance’ method can be used along with recursion.The recursion computes output of small bits of the bigger problem, and combines these bits to give the solution to the bigger problem.ExampleBelow is a demonstration ... Read More

Python Program to Reverse a String Using Recursion

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 12:24:52

2K+ Views

When it is required to reverse a string using recursion technique, a user defined method is used along with recursion.The recursion computes output of small bits of the bigger problem, and combines these bits to give the solution to the bigger problem.ExampleBelow is a demonstration for the same − Live Demodef ... Read More

Python Program to Check Whether a String is a Palindrome or not Using Recursion

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 12:23:35

3K+ Views

When it is required to check if a string is a palindrome or not using recursion technique, simple indexing and a user defined function, along with recutsion is used.Palindromes are those strings or values which when read from left to right and right to left have the same characters in ... Read More

Python Program to Find the Product of two Numbers Using Recursion

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 12:22:03

675 Views

When it is required to find the product of two numbers using recursion technique, a simple if condition and recursion is used.The recursion computes output of small bits of the bigger problem, and combines these bits to give the solution to the bigger problem.ExampleBelow is a demonstration for the same ... Read More

Python Program to Find if a Number is Prime or Not Prime Using Recursion

AmitDiwan

AmitDiwan

Updated on 12-Mar-2021 12:20:02

2K+ Views

When it is required to find out if a number is a prime number or not using recursion technique, a method is defined, and the ‘while’ condition is used.The recursion computes output of small bits of the bigger problem, and combines these bits to give the solution to the bigger ... Read More

Advertisements