DEV Community

jothilingam
jothilingam

Posted on

PRINT function in python

13-07-2024

PRINT() function

print() function is a function that allows us to output to the screen

The print() function has three different uses;

  1. Single quotes (' ')
  2. Double quotes (" ")
  3. Three quotes (“”” “””)-----------for multi line

we can use anyone type quote, cannot use different quote in same line

print()---------------------------#create empty line
Enter fullscreen mode Exit fullscreen mode
print("jothilingam")--------------#string should print with""
Enter fullscreen mode Exit fullscreen mode
print(5)------------------------#number can print without ""
Enter fullscreen mode Exit fullscreen mode
print("jo""jo")--------------print without space
print("jo"+"jo")--------------print without space
answer    jojo
print("jo","jo")--------------print with space
answer     jo jo
Enter fullscreen mode Exit fullscreen mode

print with f-strings

name = "jothi"
print(f"Hello {name}")
# Output : Hello jothi
Enter fullscreen mode Exit fullscreen mode

newline escape character \n

print("jo\nthi")
jo
thi
Enter fullscreen mode Exit fullscreen mode

Parameters of the print() Function:

sepparameter

print("jo","jo",sep="_")...................sep="" is default
answer    jo_jo
Enter fullscreen mode Exit fullscreen mode
print("jo", "lingam", sep='thi')
answer     jothilingam
Enter fullscreen mode Exit fullscreen mode

endparameter

print("jothi",end="lingam")
answer  jothilingam
Enter fullscreen mode Exit fullscreen mode
print("jothi",end="")----------------without space
print("lingam")
answer  jothilingam
Enter fullscreen mode Exit fullscreen mode
print("jothi",end=" ")----------------with space
print("lingam")
answer  jothi lingam
Enter fullscreen mode Exit fullscreen mode

* parameter

print(*"jothilingam")
answer    j o t h i l i n g a m
Enter fullscreen mode Exit fullscreen mode

fileand flushparameters, since these parameters are the parameters that allow us to process the files

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay