A function is a block of code which only runs when it is called.
why to use function?
Automate repetitive tasks
Allow code reuse
Improve code readability
Clean-up code
Allow easier refactoring
find factorial of a number
def factorial(number):
result = 1
for i in range(1, number+1):
result = result * i
return result
call the function
print(factorial(4))
Output: 24
print(factorial(5))
Output: 120
#python #python3 #function #learnbatta
https://learnbatta.com/course/python/...