What are functions in Python?

A function is a block of code which is executed only when it is called. To define a Python function, the def keyword is used.

Example:

  1. def New_func():  
  2.     print (“Hi, Welcome to lahore”)  
  3. New_func() #calling the function  

Output:

Hi, Welcome to lahore