Introduction
In this article, I will explain the function in Python. A function is a block of code which only runs when it is called. Function blocks begin with the keyword “def” followed by the characteristic name and parentheses (()). The code block within every feature starts off evolved with a colon (): and is indented. Any enter parameters or arguments have to be positioned inside those parentheses. You also can define parameters inside these parentheses.
Creating a function
“def” keyword is used to create new functions.
Syntax
- def function_name(parameters):
- """some code"""
- statement(s)
Example
- def my_function():
- print("Hello c# corner")
Calling function
To call a function, use the function keyword.
Example
- def my_function():#function
- print("Hello c# corner")
- my_function()
Output

Arguments
Information can be exceeded into functions as arguments. Arguments are unique after the function name, in the parentheses. You can add as many arguments as you want, simply separate them with a comma.
Example
- def my_function(arg_name):#Arguments name is arg_name.
- print(arg_name + " c# corner")
- my_function("hello")
- my_function("welcome")
- my_function("hi")
Output





Vijayakumar SPosted Apr 3, 2020, 8:25 AM
Nice article