Python - Recursive Function Recursive function means the function call themselves within the function body until a certain condition is matched then this function is recursive function. For example:- def fact(n): if n==0 or n==1: return 1 else: return n*fact(n-1) print(fact(8)) Output:- 40320 This is the example of recursive function. In this program we create a function named as fact and we call this function within the same function. How this program works? We give the value of n is 8 so n=8. In the first if condition, 8 is not equal to 0 and 1 so it goes to the else part in the else part the sentence is return n*fact(n-1) that means 8*fact(7) now here value of n become 7 to find fact(7) again same procedure repeat up to fact(1). Because fact(1)=1 we give this condition. Then fact(2) => 2*fact(1) => 2*1 => 2 ...
Data Type Of Python I n the last session we discus about what is the data type of python. And we see List data type. In this session we s ee the next data type String. 2) String- String is a ordered collection of immutable data type. String are iterable and hashable. Strings are always declared in single or double quotes. Single line string:- S = "Python" Multi line string:- S = """ Line 1 Line 2 Line 3 """ Iterable:- S= "Program" for i in S: print(i) Output:- P r o g r a m Membership:- print( 'p' in S) => True print( 'P' not in S) => False Methods of string:- capitalize() :- It return the capitalize version of the string. More specifically it make the first character have uppercase and rest lowercase. For example:- S = "hello World" print(S.capitalize()) => "Hello world" count(substring, start,en...