Mastering the print() Function in Python ๐๐


The print() function is often the very first line of Python code beginners write: print("Hello, world!") But there's more power packed into print() than most realize.
What is print()? In Python, print() is a built-in function that outputs text or other data to the console. It's commonly used for debugging, displaying results, and providing user feedback.
๐ ๏ธ Basic Usage
print("This is Python.")
This is Python.
You can also print numbers and variables:
name = "Alice"
print("Hello", name)
Hello Alice
๐ Separator (sep) and End (end) Parameters
You can customize the way multiple items are separated and how the line ends.
print("Python", "is", "awesome", sep=" - ")
Python - is - awesome
```python
print("This is", end=" >> ")
print("a chained print.")
This is >> a chained print
๐ Print with Formatting
You can format your output using f-strings:
age = 25
print(f"I am {age} years old.")
I am 25 years old.
๐ Final Thoughts print() is simple yet incredibly versatile. Whether you're learning Python or building large-scale apps, mastering print() will make your coding life much smoother.
๐ If you liked this post, leave a like and follow me for more Python tips and tutorials!
Subscribe to my newsletter
Read articles from Shreyansh Kumar directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Shreyansh Kumar
Shreyansh Kumar
A 2nd year student , majoring in Economics with a minor in Human resource but I am starting by journey of becoming a Data Analyst, learning new skills and stepping into a whole new exciting world.