Python: Printing various messages by utilizing various variations of print() technique

Python: Printing various messages by utilizing various variations of print() technique

In the given model, we are printing the messages by utilizing various types of print() strategy in Python.

Check the Program:

# it will print new line after the messages
print("Hello")
print("World")

# it will print new line
print()

# it will print new line after printing "Hello"
print("Hello",end="\n")
# it willprint new line after printing "World"
print("World")

# it will print new line 
print()

# it will not print new line after printing "Hello"
# it will print space " "
print("Hello",end=" ")
# it will print new line after printing "World"
print("World")

Output:

Python: Printing various messages by utilizing various variations of print() technique

Explanation:

print() prints new line subsequent to printing the message as a matter of course.

end parameter can be utilized to indicate the end character in the wake of printing the message – here in this program, we are utilizing end=”\n” and end=” “, initial one will print a newline after the message and the subsequent one will print the space in the wake of printing the message.

Leave a Comment

error: Alert: Content is protected!!