In Python, the print() function is used to output text or data to the console. It can be used to print a string, a number, or any other type of data.
For example:
print("Hello, World!")
print(5)
The print() function can also be used to print multiple items by separating them with a comma.
For example:
print("Hello,", "World!")
print(5, "is a number")
You can also use the print() function to print the result of an expression.
For example:
a = 5
b = 10
print(a + b)
The print() function also has several optional parameters that can be used to customize the output. For example, the sep parameter can be used to specify a separator between multiple items, and the end parameter can be used to specify the character that should be printed at the end of the line.
For example:
print("Hello", "World!", sep="-", end="!\n")
In summary, the print() function is used to output text or data to the console in Python, it can be used to print a single item or multiple items, it can also be used to print the result of an expression, it also has several optional parameters that can be used to customize the output like sep, end.
Comments
Post a Comment