Python Output Using print() function
Output Using print() function in Python
To see the output data of the standard output device, we utilize the print()
method (screen). Below is an example of how it can be used.
print('This is an output sentence')
Output
Output
End parameter in print()
By default, the print()
method in Python returns a newline. A C/C++ coder could be perplexed as to how to print without a newline.The print()
method in Python has an argument named 'end.' This parameter's default value is 'n,' which is the new line character. This argument allows you to terminate a print statement with any character or string.
print("Welcome to" , end = ' ')
print("Python Tutorial", end = ' ')
Output
Sep parameter in print()
By default, the separator between the inputs to the print() method in Python is space (softspace feature). However, you can change this to any character, number, or string of our preference.
To do so, utilize the 'sep' argument, which is only available in Python 3.x and later. It's also where the output strings are formatted.
Examples:
#code for disabling the softspace feature
print('W','S','C', sep='')
#for formatting a date
print('19','08','2021', sep='-')
#another example
print('abc','python', sep='@')
Output:
Test your knowledge with a quick quiz!
Which of the below functions is a built-in function in Python language?
Select the correct answer