Lesson - 22 : Python3 - Python Function : Creating functions

Опубликовано: 12 Октябрь 2024
на канале: Sada Learning Hub
46
2

**************************************************
Python Core PlayList :    • Lesson - 01 : Python3 - What is python  
Python Advanced PlayList :    • Lesson - 46 : Python Advanced - Pytho...  
**************************************************
Python Function : Creating functions:
Functions are the re-usable pieces of code which helps us to organize structure of the code. We create functions so that we can run a set of statements multiple times during in the program without repeating ourselves.

Creating functions :
A Function defined in Python should follow the following format:
1) Keyword def is used to start the Function Definition. Def specifies the starting of Function block.
2) def is followed by function-name followed by parenthesis.
3) Parameters are passed inside the parenthesis. At the end a colon is marked.

Syntax :
def functionname( parameters ):
"function_docstring"
function_suite
return [expression]

Example :
def myfunc():
    pass

Sample Projects : https://github.com/SadaLearningHub1/P...