Functions with default parameter in Python3 - Coders PlayGround

Learn to code and change the future!

Tuesday, 29 August 2017

Functions with default parameter in Python3



Hello friends, lets learn something more about functions in Python3.

We can set default parameters in the function.

Check the following code:

def simple(num1, num2):
  pass

def simple(num1,num2=5):
  print("Number 1 and Number 2 default")
  print(num1,num2)

def class_a(name, roll_no, branch = "IT", strength_of_class = 90):
  print (name, '\n', roll_no,'\n',branch,'\n',strength_of_class)


simple(10)
simple(10,20)
class_a('Kevin',38)


Output



PropellerAds