Skip to content

Print Command in Python

print() statement:

The print() statement is a very important statement in the language of Python. This command is used to print a variety of things. It can be used in conjunction with lists, strings, integers, tuples and dictionaries (it can also do calculations). It takes three kinds of arguments:

  1. value(s) to be printed

Eg: >>>print(‘hello. i am learning python’)

   hello. i am learning python

Here , ‘hello. I am learning python’ is the argument given.

 

  1. separating character or string

This is done by using the sep parameter in Python. The sep statement is used to specify the character or string that separates two or more values inputted into the print() statement.

By  default, the separator is an empty space, i.e. ‘  ’.

Eg: >>>print(‘hello’, ‘i am learning python’, sep=‘!’)

   hello!i am learning python

 

 

  1. ending character or string

This is done by using the end parameter in Python. The end statement is used to specify the character or string that ends two or more values inputted into the print() statement.

By default the value of the end parameter is \n, i.e. new line.

Eg: >>>print(‘hello’, ‘i am learning python’, sep=‘!’, end=‘!’)

   hello!i am learning python!

 

 

1 thought on “Print Command in Python”

  1. Pingback: Introduction to Python – Freakgenie

Comments are closed.