Alright, let’s start with what functions actually are?
- OK, a function is a piece of code.
- A function may/may not accept input(s).
- A function may/may not return an output(s).
Why do we need functions in a program?
- Well, the Reusability of the code in a program is made possible through functions.
- The program can call these so-called functions, n - number of times.
- This showcases the best practice in a program called DRY.
DRY - Do not Repeat Yourself
- A code is said to be DRY if any given code does not repeat certain tasks.
- A function implements this just by writing once and using it whenever necessary.
#python #python3 #programming