Functions with Parameter in Python3 - Coders PlayGround

Learn to code and change the future!

Tuesday, 29 August 2017

Functions with Parameter in Python3


Functions with parameter

Hello friends, It is also possible to define functions with a variable number of arguments. 

Let us look at the code:

Here we define two parameters, num1 and num2. Then while calling the function we can pass the value to the function.

def simple_addition(num1, num2):
  answer = num1 + num2
  print ("Num1 is:", num1)
  print ("Num2 is:",num2)
  print ("Addition:", answer)


simple_addition(5,10)
simple_addition(num1 = 10, num2 = 5)
simple_addition(num2 = 5, num1 = 10)
'''
same no of parameters should be passed
'''
 
Output
 
 
 
 
 
 
 
 
PropellerAds