newtum

Our Social Network

YOUR FIRST PYTHON PROGRAM : PRINTING WITH STYLE

Your First Python Program: Printing with Style

Learning Python can be exciting, especially when you see your first output on the screen. In this guide, we'll walk you through writing your first program using Python’s print() statement. We’ll start by understanding where to write code, then move to print text, use new lines, tabs, and escape characters — all important basics to kickstart your Python journey.

Understanding the Basics of Print in Python

When starting with Python, the first thing you usually write is a simple program to print a message. You can write Python code in several environments, like downloading Python from the official site, using Anaconda with Jupyter Notebooks or Spyder, or installing IDEs like PyCharm. However, for absolute beginners, using an online compiler is the easiest and fastest way to get started.

The print() statement is a built-in Python function used to display messages or output. You write your desired text inside double or single quotes within parentheses. It's important to note that Python is case-sensitive, so you must use lowercase print.

Here’s what we explored:

  • To display simple text, use: print("Hello")
  • Each print() command outputs on a new line by default
  • For new lines within a single print, use \n (newline escape character)
  • For tabbed space, use \t (tab escape character)

Combining multiple lines and formatting them in a single print command gives you control over how your output looks. These basic formatting tools help build your understanding of more complex outputs, which we’ll cover in future lessons.

Sample Python Code

1# First Python Program
2print("Hello")
3# Printing using new lines
4print("C")
5print("C++")
6print("C#")
7# Using \n to print in one line
8print("C\nC++\nC#")
9# Using \t for tabbed output
10print("C")
11print("\tC++")
12print("\t\tC#")

Code Explanation

  • Line 1: Prints "Hello" as basic output.
  • Lines 3-5: Each print() outputs on a new line by default.
  • Line 7: Uses \n to add line breaks inside a single print() call.
  • Lines 9-11: Uses \t to add tab spaces before the text for formatting output.

Output of the Code

Hello
C
C++
C#
C
C++
C#
C

Watch the Video

If you're just starting your Python learning journey, don’t miss the full video on our Newtum YouTube channel. We’ve explained every step visually, so you can follow along easily. Watch the Full Video Tutorial on YouTube:

Conclusion

In conclusion, using print() is your first step in Python. It may look simple, but it’s a powerful way to control how your program communicates with the user. Start small, stay consistent, and you’ll build great things with Python!

From 'Hello World' to real-world applications — your Python journey starts with mastering the basics.

— Manoj Kolhe

More Articles

Ready to Explore the Future of Technology?

Unlock the tools and insights you need to thrive on social media with Newtum. Join our community for expert tips, trending strategies, and resources that empower you to stand out and succeed.

Newtum

Newtum is an emerging online academy offering a wide range of high-end technical courses for people of all ages. We offer courses based on the latest demands and future of the IT industry.

© Newtum, Inc. All Rights Reserved.