"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > PRINT function in python

PRINT function in python

Published on 2024-08-16
Browse:584

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
print("jothilingam")--------------#string should print with""
print(5)------------------------#number can print without ""
print("jo""jo")--------------print without space
print("jo" "jo")--------------print without space
answer    jojo
print("jo","jo")--------------print with space
answer     jo jo

print with f-strings

name = "jothi"
print(f"Hello {name}")
# Output : Hello jothi

newline escape character \n

print("jo\nthi")
jo
thi

Parameters of the print() Function:

sepparameter

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

endparameter

print("jothi",end="lingam")
answer  jothilingam
print("jothi",end="")----------------without space
print("lingam")
answer  jothilingam
print("jothi",end=" ")----------------with space
print("lingam")
answer  jothi lingam

* parameter

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

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

Release Statement This article is reproduced at: https://dev.to/jothilingam88/print-function-in-python-35jj?1 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3