Skip to content

Hello World & The Print Function

The “Hello, World!” program is a venerable tradition. While it seems trivial, successfully running it confirms that your interpreter, editor, and environment are all working in harmony.

However, beneath this simple line of code lies the foundation of how Python communicates with the outside world.


  1. Open VS Code and create a file named hello.py.
  2. Type: print("Hello, World!")
  3. Run the script: python hello.py

Output:

Hello, World!

The line print("Hello, World!") is a Function Call.

  • print: The name of a built-in function provided by the Python language.
  • (...): The “Invocation Operator.” It tells Python to execute the function.
  • "Hello, World!": A String Literal. This is the data (the Argument) passed into the function.

When you call print(), Python sends data to a stream called sys.stdout. By default, this stream is connected to your terminal window. In professional environments, you might redirect this stream to a log file or a database.


Most beginners think print() only takes one argument. In reality, it is a highly flexible tool with several hidden parameters.

You can pass multiple items separated by commas. Python will automatically join them with a space.

print("Hello", "Python", 2026)
# Output: Hello Python 2026

By default, sep is a space " ". You can change it to anything you like.

print("Apple", "Banana", "Cherry", sep=" | ")
# Output: Apple | Banana | Cherry

By default, every print() call ends with a newline character (\n), which moves the cursor to the next line. You can override this to keep multiple prints on the same line.

print("Loading", end="... ")
print("Complete!")
# Output: Loading... Complete!

When you call print(), the text doesn’t always go to the screen instantly.

To be efficient, the operating system uses a Buffer. It collects characters in memory and only “flushes” them to the screen once the buffer is full or a newline is encountered.


Python is case-sensitive. Print() will cause a NameError.

print(Hello) will cause a NameError because Python thinks Hello is a variable that hasn’t been defined yet. You must use quotes to indicate it is a literal string.

  • SyntaxError: print("Hello" (Missing a parenthesis). Python won’t even start the program.
  • RuntimeError: print(1/0) (Dividing by zero). Python starts the program, but crashes when it hits that specific line.

Create a script that uses the sep and end parameters to print a simple “Loading Bar” that looks exactly like this on a single line:

[===] 100% DONE

Solution
print("[", "===", "]", sep="", end=" ")
print("100%", "DONE")