In this tutorial, you'll learn how to create your first Python program: the classic "Hello, World!" example. This is your first step into the world of programming.

"If you can write 'hello world', you can change the world." — Raghu Venkatesh

Creating a New Python Project

Steps:

  1. Create a Directory:

    • Create a folder named helloworld anywhere on your computer (e.g., C:\helloworld or ~/helloworld).

  2. Open in VS Code:

    • Launch Visual Studio Code.

    • Open the helloworld directory.

  3. Create a Python File:

    • Create a new file named app.py.

    • Enter the following code and save it:

print('Hello, World!')

The print() function is a built-in Python function that displays a message on the screen.

What is a Function?

A function is a reusable piece of code that takes inputs, applies some logic, and returns an output.

Examples:

  • Sum of two numbers

  • Multiplication of two numbers

In our example, print() is a function:

  • It accepts a string as input.

  • It outputs the string to the screen.

Python offers many built-in functions, and you can also create your own.

Executing the Python Hello World Program

Run from Command Line:

  1. Open Terminal or Command Prompt

  2. Navigate to the helloworld directory:

cd path/to/helloworld
  1. Execute the Python file:

  • On Windows:

python app.py
  • On macOS/Linux:

python3 app.py

If everything is correct, you should see:

Hello, World!

Run Inside VS Code:

  • Open the menu: Terminal > New Terminal

  • Shortcut: `Ctrl+Shift+`` (backtick key, usually under the Esc key)

  • Then run:

python app.py

Using Python IDLE

Python comes with a simple editor called IDLE (Integrated Development and Learning Environment).

Features of IDLE:

  • Syntax highlighting

  • Smart indentation

  • Auto-completion

How to Use IDLE:

  1. Launch IDLE (find it in your installed apps).

  2. A Python Shell window will open.

  3. After the >>> prompt, type:

print('Hello, World!')
  1. Press Enter and you'll immediately see the output.

IDLE is great for quick experiments and learning.

Summary

  • Create a Python file and use print() to display messages.

  • Execute Python scripts via Command Line, Terminal, or directly inside VS Code.

  • Use Python IDLE for quick testing and learning.

Congratulations! You've just written and run your first Python program!