This guide explains print() Function: Usage and Examples through a focused example and practical reasoning. No prior knowledge of this specific operation is required.
Understanding the Concept
print() sends a readable representation of values to standard output. It supports multiple arguments, a custom separator (sep) and line ending (end); those options affect display, not the values stored in variables.
When You Would Use This
Create a simple labelled receipt without concatenating every value by hand.
Step-by-Step Example
product_name = "Pencil"
quantity = 3
print("Item", product_name, sep=": ")
print("Quantity:", quantity)
print("Ready", end=" — ")
print("thank you")
How the Example Works
The first call inserts : between its two arguments. The final two calls appear on one line because end replaces the usual newline after Ready.
Example Output
Item: Pencil
Quantity: 3
Ready — thank you
Try It Yourself
Print three columns of data with sep=" | ", then change end to control line breaks.
Common Beginner Mistakes
- Expecting
print()to return the text it displays; it returnsNone. - Forgetting that commas between arguments insert a separator by default.
- Mixing
print()output with a function result when a value must be reused later.
Key Takeaways
print()sends a readable representation of values to standard output.- The first call inserts
:between its two arguments. - Avoid this mistake: Expecting
print()to return the text it displays; it returnsNone.