How to define a function in Python
What you will learn here about Python
- How to define a function in Python
- Python name error name is not defined
How to define a function in Python
1)In Python def keyword helps us to define a function
2)The sample example of defining a function in python is shown below
def numberSum(a,b): print("Sum of numbers is : "+str(a+b)); numberSum(10,50);
Python name error name is not defined
1)You will get error Python name error name is not defined when you are trying to call function or variable before the declaration.
2)The sample example for Python name error name is not defined is given below
numberSum(10,50); def numberSum(a,b): print("Sum of numbers is : "+str(a+b));