FUNCTIONS IN PYTHON

Khan Asif Salim
2 min readSep 27, 2021

FUNCTIONS IN PYTHON:-

REUSABILITY:-

  • The Major Uses Of Writing Function Is Reusability.
  • Reusability Means Once We Write Any Function That Function Can Be Called A Number Of Times.

EASY DEBUGGING:-

  • Easy Debugging That Means The Finding Of Error Is Easy For User If We Write This Function.

FUNCTION DEFINATION:-

  • Function is Totally Based On Your Dry Concept Which Means “Don’t Repeat Yourself”. Which Means We Don’t Have To Write The Whole Program Again And Again,Instead We Can Make a Function Of That Program And Use It Whenever We Want Just Calling The Function Name.
  • Every Function Should Start With “def” Keyword.
  • Every Function Should Have Name.
  • Every Function Name With/Without Argument Should End With (:).
  • Try To Avoid Writing a Print Statement Inside a Function , Instead Of Print , Write “return” Keyword.

SYNTEX:-

Type Of Functions:-

BUILT IN FUNCTIONS:-

  • Python Has 63 Built-in Function That Are Readily Available For Use. These Functions Are Called Built-in Functions.

USER DEFINED FUNCTION:-

  • Functions That We Define Ourselves To Do Certain Specific Task Are Referred As User Defined Functions.

LAMBDA FUNCTION:-

  • This Functions Do Not Defined By “def” Keyword And This Function Will Return Expression But Not Value.
  • This Function Are One Line Functions.
  • It Can Take Any Number Of Arguments.
  • It Cannot Access Global variables.
  • This Function Will Be Defined By Using “lambda” Keyword.

SYNTEX:-

--

--