In the last article, we have seen how a user-defined function is created. The user-defined function has two parts – the function definition and the function call.The function definition may or may not have parameters and it may or may not return a value.
In this article, you will see an example of python function with no parameters, and no return.
Program to Compute Factorial of a Number
This program is a simple program that computes factorial of a given input number.
## Program To Compute Factorial of a Number ## Function Definition def factorial_number(): factorial = 1 fact_number = int(input("Enter a Number to Get its Factorial: ")) for i in range(1, fact_number + 1): factorial = factorial * i print("The factorial is" , factorial) ## Function Call factorial_number()
The above program does not take any parameters and does not return anything. The output of the program is given below.
========= RESTART: C:/Python_projects/Functions/Factorial.py ============= Enter a Number to Get its Factorial: 5 The factorial is 120 >>>
In the next article, we will discuss about function with parameter with return.