Skip to main content
  • Python is available now. All other compilers are coming soon.

    Python
  • Popular Tutorials

    • Getting Started With Python
    • Python if Statement
    • while Loop in Python
    • Python Lists
    • Dictionaries in Python
    All Python Tutorials

    Reference Materials

    Built-in FunctionsList MethodsDictionary MethodsString Methods
    View all

Online Compilers

  • Python Compiler
  • Python Playground
  • Python Projects
  • Exercises

Tutorials

  • Learn Python
  • Python for Beginners
  • Variables and Types
  • Python Strings
  • Python Lists
  • Python If Else
  • Python For Loops
  • Python Functions
  • Python Classes

Examples

  • Python Examples
  • Hello World
  • Add Two Numbers
  • Even or Odd
  • Factorial
  • Fibonacci
  • Prime Check
  • Palindrome Check

Company

  • About
  • Contact
  • Privacy Policy
  • Terms of Use
  • Disclaimer

© 2026 ILoveCompiler. All rights reserved.

  1. Home
  2. Python Examples
  3. Hello World in Python

Basic Programs · Python example

Hello World in Python

The classic first program: print a greeting and a second line of text.

Open the compilerAll examples
beginnerprintstringsfirst program

A Hello World program confirms that Python is working and introduces print(), the function used to send text to standard output.

example.py
print("Hello, World!")
print("This program runs in your browser.")

How the code works

  • Python evaluates the two string literals.
  • print() sends the first string to the console and moves to a new line.
  • The second print() does the same with the second string.

Key ideas

  • Text wrapped in quotes is a string.
  • print() writes its arguments to standard output, followed by a newline.
  • Each print() call starts a new line.

Try changing it

  • Print a personalised greeting with an f-string.
  • Use a loop to print several greetings.
  • Call print() with two arguments to see how spaces are inserted automatically.

Related examples

beginner

Variables and Data Types

Create strings, integers, floats, and booleans, then inspect each type.

beginner

A Function with a Default Argument

Define a reusable greeting function with a default parameter value.

Next exampleAdd Two Numbers

Expected output

Hello, World!
This program runs in your browser.

Output is compared after trimming trailing whitespace on each line. Run the code to see it produced by CPython in your browser.

Practice next

Apply the same idea with automatic tests or browse a guided project.

ExercisesProjects