print()
Function Guideprint()
?The print()
function in Python is used to display output on the screen. It's commonly used for printing text, variables, numbers, or results of expressions.
print(value1, value2, ..., sep=' ', end='\n')
print("Hello, world!")
print(42)
name = "Alice"
age = 25
print("Name:", name, "Age:", age)
print("apple", "banana", "cherry", sep=", ")
print("Hello", end=" ")
print("World")
a = 5
b = 3
print("Sum:", a + b)
name = "Bob"
score = 90
print(f"{name} scored {score} points.")
The print()
function is essential for debugging and displaying output in Python. It supports formatting and customization through sep
, end
, and f-strings.