Python sep parameter in Python:

Python for Data ScienceSpace as default acts as a separator between the arguments to print() function in Python for Data Science or in general. But we have a choice of modifying this to any character, integer or string. The ‘sep’ parameter comes in use for this kind of modification. This is also used for formatting output strings. We should keep in mind that the ‘sep’ parameter is only available in Python 3.x and later version.

Let’s look at some examples:

#code for disabling the softspace feature

print(‘P’,’S’,’T’, sep=”)

#for formatting a date

print(’24’,’07’,’2019′, sep=’-‘)

#another example

print(‘Kathan’,’PSTAnalytics’, sep=’@’)

Output:

PST

24-07-2019

Kathan@PSTAnalytics

The results obtained by combining sep and end parameters are awesome. Lets look at some examples.

print(‘P’,’S’, sep=”, end=”)

print(‘T’)

#n takes to new line after printing the year

print(’24’,’07’, sep=’-‘, end=’-2019n’)

print(‘sammy’,’gupta’, sep=”, end=’@’)

print(‘PSTAnalytics’)

Output:

PST

24-07-2019

sammygupta@PSTAnalytics

Changing from Python to Python 3 in online ide for data science.

Type python in your cmd for windows or terminal for linuxto go to your interactive python ide.

#import the module antigravity and see what happens

import antigravity

#NOTE – it won’t work on online ide

To understand it better, you can check this and this.

Leave a Reply

Your email address will not be published. Required fields are marked *