Showing Messages on the Screen
Every app needs a way to talk to the user. In Python, we use the print() command to show text, numbers, or results on the screen.
1. Printing One or More Things
At its simplest, you can pass a single piece of text to print():
print("Welcome to Think IT Telugu")
You can also print multiple things at the same time by separating them with commas. Python will automatically put a single space between them:
user_name = "Sai"
active_sessions = 3
print("User:", user_name, "Sessions:", active_sessions)
# Output: User: Sai Sessions: 3
2. Special Characters (\n and \t)
Sometimes you want to format your text - like starting a new line or adding a big space. You can do this using special combinations called escape characters:
\n(New Line): Acts like pressing the "Enter" key on your keyboard. It moves the text after it to a new line.print("First Line\nSecond Line")# Output:# First Line# Second Line\t(Tab Space): Acts like pressing the "Tab" key. It inserts a big blank space (usually 4 spaces).print("Name:\tSai\nAge:\t25")# Output:# Name: Sai# Age: 25
3. Customizing print() with sep and end
By default, when you separate items with a comma, Python puts a space between them. Also, every time a print() command finishes, it automatically goes to a new line.
You can change this behavior using two special controls:
Custom Separator (sep)
By default, the separator between items is a space. You can change it to whatever you want using sep=:
# Format a date using hyphens instead of spaces
print("2026", "07", "01", sep="-")
# Output: 2026-07-01
# Print website domain
print("www", "google", "com", sep=".")
# Output: www.google.com
Custom Line Ending (end)
By default, Python moves to a new line at the end of a print() command. You can keep it on the same line using end=:
# Keep the next print on the same line by ending with a space instead of a new line
print("Loading data...", end=" ")
print("Done!")
# Output: Loading data... Done!
What's Next?
Now that you know how to make Python talk to the user, let's learn how to ask the user questions and get their answers in the next lesson!