4. A function in Python is a block of organized, reusable code that
performs a specific action.
Functions provide better modularity for applications by
breaking down tasks into smaller, manageable parts.
Introduction :
5. A function in Python is a block of organized, reusable code that
performs a specific action.
Functions provide better modularity for applications by
breaking down tasks into smaller, manageable parts.
Introduction :
6. Use of Functions
You use functions in programming to bundle a set of instructions that
you want to use repeatedly or that, because of their complexity, are
better self-contained in a sub-program and called when needed.
Functions helps you to make your program:
Functions in Python
Shorter
Less complex
Easy to Debug
7. Structuring
Code
More Readable
Maintainable
Promoting
Efficiency
Functions add structure to our programs and
make them easier to read and modify over
time.
A function separates responsibilities for a
specific part of a task, making the main task
easier to work with and read.
The functions make our code easy to
maintainable, debugable and easy to
understand. It also make our code easy for
future updates.
Using in functions make your code or program
more Efficient.
Need
of
Function
8. • Use the keyword “def” to declare the function
and follow this up with the function name.
• Add parameters to the function: they should
be within the parentheses of the function.
• End your line with a colon. Add statements
that the functions should execute.
How to create a Function
9. • Use the keyword “def” to
declare the function and follow
this up with the function name.
Syntax of Function: