Lesson 4: print() function in python | formatting using print function in python | output formatting

Publié le: 18 août 2024
sur la chaîne: VCODE LOGIC
10
0

The print() function in Python is one of the most commonly used functions,
and its primary purpose is to output data to the console


Formatting the Output:

name="vcode logic"
age=100

1.Concatenation:

print("Name: " + name + ", Age: " + str(age))

2. f-Strings (Python 3.6+):

print(f"Name: {name}, Age: {age}")
{} is place holder
A placeholder can fcontain variables, operations, functions, and modifiers to format the value.

3.Controlling the End of Output:
print("Hello", end=" ")
print("World!")

Printing Special Characters
You can use escape characters to include special characters in your output:

\n: Newline
\t: Tab
\\: Backslash
\": Double quote
\': Single quote


Sur cette page du site, vous pouvez voir la vidéo en ligne Lesson 4: print() function in python | formatting using print function in python | output formatting durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur VCODE LOGIC 18 août 2024, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 10 fois et il a aimé 0 téléspectateurs. Bon visionnage!