Free Python Course
Kanalga Telegram’da o‘tish
Ko'proq ko'rsatish
5 967
Obunachilar
Ma'lumot yo'q24 soatlar
-357 kun
-22530 kun
Postlar arxiv
5 967
RECURSION EXAMPLE
This is a recursive function to find the factorial of an integer
5 967
DISADVANTAGE OF RECURSION
Sometimes the logic behind recursion is hard to follow through.
Recursive calls are expensive (inefficient) as they take up a lot of memory and time.
Recursive functions are hard to debug.
5 967
ADVANTAGE OF RECURSION
Recursive functions make the code look clean and elegant.
A complex task can be broken down into simpler subproblems using recursion.
Sequence generation is easier with recursion than using some nested iteration.
5 967
RECURSION
Python also accepts function recursion, which means a defined function can call itself.
Recursion is a common mathematical and programming concept. It means that a function calls itself.
This has the benefit of meaning that you can loop through data to reach a result.
5 967
ARGUMENT OR PARAMETER ?
The terms parameter and argument can be used for the same thing: information that are passed into a function.
From a function's perspective :
A parameter is the variable listed inside the parentheses in the function definition.
An argument is the value that is sent to the function when it is called.
5 967
EXAMPLE 1 : FUNCTION WITH ONE ARGUMENT
def myFunction(fname):
print("Hello " + fname)
myFunction("Rushi")
myFunction("Atharva")
myFunction("Aniket")
Output
Hello Rushi
Hello Atharva
Hello Aniket5 967
ARGUMENT
Information can be passed into functions as arguments.
Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma.
The following example has a function with one argument (fname). When the function is called, we pass along a first name, which is used inside the function to print the full name:
5 967
EXAMPLE :
def welcome():
print('Welcome to CodeWithRushi')
# call the function
welcome()
print('Outside function')
Output
Welcome to CodeWithRushi
Outside function5 967
CALLING A FUNCTION
In Python a function is defined using the def keyword:
def my_function():
print("Hello from a function")5 967
CREATING A FUNCTION
In Python a function is defined using the def keyword:
def my_function():
print("Hello from a function")5 967
TYPES OF FUNCTION
There are two types of function in Python programming:
Standard library functions - These are built-in functions in Python that are available to use.
User-defined functions - We can create our own functions based on our requirements.
5 967
WHAT IS FUNCTION ?
A function is a block of code which only runs when it is called. You can pass data, known as parameters, into a function. A function can return data as a result.
5 967
Get Free Python Course Pdf Access Now 👍
Link : https://shrs.link/6zQ8wy
This offer is only available for 7 days download pdf fast🔥
5 967
Get Codes Of Url Shortner Bot
🔗 Link : https://shrs.link/k53zY8
Watch Video Then You Will Know How To Get The Codes
5 967
WHAT WILL YOU LEARN :
1. What is Function ?
2. Types of Function
3. Parameter or Arguments
4. Recursion
5. *args and **kwargs
6. Lambda Expression
7. Map Function
8. Zip Function
9. Any & all Function
10. Reduce Function
11. Max & Min Function
12. Filter Function
