Tuesday, 3 December 2019

Calling a Function:


Calling a Function:
A function can not run/execute its own. It runs only when we call the function by using its name, while calling the function, we should pass the necessary values(parameters) to the function in the parenthesis.
Ex: sum(2,3) # Here sum is a function call, we are passing values 2, 3 to the function.
When this statement sum(2,3) executed, the python interpreter goes to the function definition.
Example:

def test(b):
    print("b=",b)

Note:
test(2)




Parameters:
Parameters are the inputs to the function. If a function contains parameters, then at the time of calling, compulsory we should provide values otherwise, we will get error.

Next: Return statement
Prev: Functions

No comments:

Post a Comment

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(&qu...