- Mastering Python Scripting for System Administrators
- Ganesh Sanjiv Naik
- 75字
- 2021-07-02 14:00:29
Functions
A function is a set of statements that perform a specific task. Using functions helps in breaking our program into smaller parts. Programs will be more organized if we use functions as it avoids repetition and makes code reusable. Look at the following syntax:
def function_name(parameters):
statement(s)
Refer to the following example:
def welcome(name):
print("Hello " + name + ", Welcome to Python Programming !")
welcome("John")
Output:
Hello John, Welcome to Python Programming !