Recursion: ========== ==> The function can call itself again and again until the completion of task. That function is called as "Recursive Function" That procedure is called as "recursion". def fun(): implementation fun() def factorial(num): fact = 1 if num == 0: return fact elif num > 0: i = num while i != 0: fact = fact * i # 5 * 4 = 20 60 120 120 i = i - 1 # 4 3 2 1 return fact else: return "Factorial is not possible for negative numbers." n = int(input("Enter an integer:")) result = factorial(num = n) print("The Factorial of the number",n,"is = ",result) =========================== def fun(): implementation fun() # WAP TO FIND THE FACTORIAL OF THE NUMBER USING RECURSION. def findFactorial(num): fact = 1 if num == 0: return fact elif num > 0: return (num * findFactorial(num-1)) # 5 * 4! ==> 5 X 4 X 3! ==> 20 X 3 X 2! ==> 60 X 2 X 1! ==> 120 X 1 X 0! ==> 120 X 1 ==> 120 else: return "Factorial is not possible for negative numbers." n = int(input("Enter a positive number:")) result = findFactorial(num = n) ================================================== Nested Functions: ================= writing a function definition inside another function definition def fun1(): implementation def fun2(): implementation # nested function def outer(): print("I am the implementation of outer function.") def inner(): print("I am the implementation of inner function.") inner() outer() # inner() ================================================= How to pass a string as an argument to the function: ==================================================== def greetings(name): print("Good Morning",name) name = input("Enter the name:") greetings(name) ============================= def reverseString(string): reverse = "" for i in string: reverse = i + reverse # "leveL" return reverse data = input("Enter the string data:") print("The Reverse of the string = ",reverseString(data)) ==================================== Passing of Collection of to the function: ========================================= def Average(*args): s_total = 0 for i in args: s_total += i avg = s_total/len(args) return avg result = Average(1,2,3,4,5,6,7,8) print(result) # ld = (10,20,30,40,50,60) # res1 = Average(ld) # print(res1) ================================ def function(ld): even_list = [] for i in ld: if i % 2 == 0: even_list.append(i) return even_list ld = eval(input("Enter a list:")) res_list = function(ld) print(res_list)