51 Program to display message using function in Python

Program 1:

#function to print a msg

def display():              # defining function

   

    """displays a msg"""    # document string--->optional

    print("Good Morning")   #stmt



display()  # calling a function, then only it executes

display()

display()

#display fn called for 3 times, so executes for 3 times



#advantage of functions is code resuability,

#only once it is declared,can be executed for many times


Output:

Program to display message using function in Python

Previous
Next Post »