Python Basics

Hello World in Python

Every Python program starts with print(): it writes text to the screen, which is how you see what your code is doing.

What is Hello World?

Every Python program starts with print(): it writes text to the screen, which is how you see what your code is doing.

Write your first Python program and print text with print().

When should you use it?

  • Learn Python syntax through a practical example.
  • Build a foundation for larger programming problems.
  • Test an idea quickly without a local setup.

Example code

Run code →
main.py
# print() writes text to the screen, followed by a new line.
print("Hello, World!")

# Several values in one call are separated by a space.
print("Python", "is", "fun")

# sep and end change what goes between values and at the end of the line.
print("2026", "11", "01", sep="-")
print("No new line here...", end=" ")
print("continued on the same line.")

Expected output

Hello, World!
Python is fun
2026-11-01
No new line here... continued on the same line.

How it works

print() accepts several values and separates them with a space. The sep argument changes that separator, and end replaces the new line printed at the end.

Change the values and run the program in the CodeUtility online Python compiler without installing Python locally.

Practice exercises

Modify the runnable example with the exercises below to build understanding beyond copying the result.

  1. Change the input and predict the output before running.
  2. Handle empty or invalid input.
  3. Wrap the logic in a function and add more test cases.
Run in Python IDE →

Practice with a challenge

Use what this lesson covers to solve a real problem. Each challenge runs in your browser with instant tests and an AI review.

All challenges