Introduction to Functions

Function is a named sequence of statements that performs a computation. When creating function you need to specify the name and the sequence of statements. Later in program code you “call” the function by typing the function name. So far we’ve met certain Python built in functions and applied function call. When you type:
>>>x = 5
>>>type(x)

You called the function type which is Python built in function. The expression in parenthesis after the function name is called an argument. Some functions need an argument in order to perform a computation. The argument or a variable is passed into the function as input to the function. The result, for the type function is the type of the argument which can be str, int, float, Boolean…
Usually we say that function takes an argument and returns a result. The result is called the return value.
Two types of functions exist and these are:
-          User defined functions and

-          Built in functions 

Nema komentara:

Objavi komentar