Home »
Python »
Python programs
Python program to print given text using a user-defined method
Printing text using a user-defined method: Here, we are going to learn how to define a user-defined method, we are implementing a method that will accept a text/string and print it through the method?
Submitted by IncludeHelp, on August 06, 2019
The task to create a user-defined method and we have to pass a text/string that should be printed on the screen.
In the below program, we are defining a method named putMe() it will accepts a string/text and print it on the screen using print() python.
Python code to print text/string using user-defined method
# Python code to print text/string using
# user-defined method
# function defintion of "putMe()"
# it will accepts a string and print it on the screen
def putMe(text):
# printing text on the screen
print(text)
# main code
if __name__ == '__main__':
putMe('Hello world!')
putMe('Welcome @')
putMe('IncludeHelp')
putMe('The world of programming')
putMe('A programming community for developer and students')
Output
Hello world!
Welcome @
IncludeHelp
The world of programming
A programming community for developer and students
Python Basic Programs »
ADVERTISEMENT
ADVERTISEMENT