So now we have learned to make a simple calculator.

But there we have not used function calls.
if you have missed it read it.

By using functions we can make that program much simpler than the one we had once written.

fun call

For using functions, we have to define the function first.

Now to learn that just look the code snippet:

def show():
 print("function called is successfully")
 return()

Here the keyword ‘def’, is used to define the function.

The name of the function used here is ‘show’ and  the name of the function which is to be

defined is to be written after the key word ‘def’. then put ‘()’ and then ‘:’ .

The ‘brackets’ or ‘()’ is used to pass the parameters.

In our code no parameters are to be passed into the function. So the brackets are empty.

After this line, in the next one we write the statements that we need to execute using this function.
This is must be written with proper indentation as i have already mentioned in a previous program

Then we have written the ‘return’ statement.

If the function is intended to return some values to the main program, then its written within the brackets.

Here we do not require one. So it is written empty.

Then comes the main segment of our program.
But it is very simple as it contains only one line, which is the function call.

Here in the function call, the brackets are empty because the are no parameters which is to be
passed into the function.

And hence we obtain our result.

fun call1111

 

 

                          ………………………………………….coding is fun………………………………………

 

Advertisements