जब कोई function खुद को call करता है directly or indirectly तो वह Recursive या Recursion Function कहलाता है। Recursion एक ऐसा process है , जो loop के तरह काम करता है। Recursion में भी loop की तरह ऐसी condition लगायी जाती है कि काम हो जाने के बाद condition false हो जाये और recursive function काम करना बंद कर दे नहीं तो Recursive Function तब तक call होता रहता है, जब तक उसकी condition false नहीं होती। अगर Recursive function की condition false नहीं हो तो ‘infinite looping’ की संभावना होती है। लेकिन Python में ये situation infinite ना होकर 1000 times तक रन होती है।
- Direct recursion:- जब एक function खुद को अपनी Function Body से directly call करता है।
- Indirect recursion:- जब एक function दूसरे function को call करता है जो इसके caller function को call करता है।
Example of Recursion Function:- def myfun(); print("estudyhelper") myfun() Output: estudyhelper
इन्हें भी देखें।
- while loop
- for loop
- nested loops
- loop control statements (Break, Continue, Pass)
- if statement
- if-else statement
- if-elif statement
- nested if statement
- range() function
- keywords
- Identifiers (names)
- Literals
- Operators
- punctuatorts
Python Programs के लिये यहाँ click करें।