Function in Python

  

Code Example


Example 1:

def full_name():
      print("My name is : Kuntal Samanta")

full_name()
output : My name is : Kuntal Samanta


Example 2:

def full_name(fn, ln):
      print("My name is : ", fn, " ", ln)

full_name("Kuntal", "Samanta")
output : My name is : Kuntal Samanta


Example 3:

def full_name(fn="Firstname, ln="Lastname"):
      print("My name is : ", fn, " ", ln)

full_name()
output : My name is : Firstname Lastname

full_name("Kuntal", "Samanta")
output : My name is : Kuntal Samanta


Example 4:

def add(x, y):
      return  x + y


result = add(10, 20)
print(result)
output: 30


Example 5:

def demo(x, y):
      return  x, y


r1, r2 = demo(10, 20)
print(r1, r2)
output: 10, 20


Quiz Level 1

Quiz Level 2


Request Me




Comments

Popular posts from this blog

How To Create .ENV File in Python

Create a Large file for Test Data Processing using Python

How to solve the Liner Equation using Python