Posts

Showing posts with the label user defined functions

19.Functions-definition, calling functions,arguments, return value

Image
So far we have only seen the functions which come with Python either in some file (module) or in interpreter itself (built in), but it is also possible for programmer to write their own function(s) and are called User Defined Functions . These functions can then be combined to form a module which can then be used in other programs by importing them. Types of Functions Basically, we can divide functions into the following two types: Built-in functions  - Functions that are built into Python. User-defined functions  - Functions defined by the users themselves. In Python, a function is a group of related statements that performs a specific task.This operation is specified in a function definition. The following are the two simple reasons to write a function Creating a new function gives you an opportunity to name a group of statements. Functions can simplify  a program by hiding a complex computation behind a single command. Creating a new function can make a program smaller by eliminatin