Python First Program


Writing your first Python program is an exciting and essential milestone in your programming journey. The "Hello, World!" program is a simple yet crucial example that introduces you to the fundamentals of Python syntax and helps you get familiar with the Python environment.


How to Write Your First Python Program

Here’s a step-by-step guide to writing the Hello, World! program in Python:


1. Set Up Your Python Environment

  • If you haven't already installed Python, follow the instructions from the Python installation guide to get Python up and running.
  • Open your Python IDE (VS Code, PyCharm, or Jupyter Notebook) or a simple text editor (e.g., Notepad on Windows, TextEdit on macOS).

2. Write the Code

In the editor, type the following Python code:


print("Hello, World!")

3. Explanation of the Code

  • print: The print() function is used to display the output on the screen.
  • "Hello, World!": This is the string that you want to print. The text is enclosed within double quotes (""). Strings can also be enclosed within single quotes ('') in Python.

4. Run the Program

  • Save the file with a .py extension (for example, hello_world.py).
  • If you are using an IDE, simply click Run.

4. Run the Program

  • Save the file with a .py extension (for example, hello_world.py).
  • If you are using an IDE, simply click Run.
  • If you're using a text editor, open the Command Prompt (Windows) or Terminal (macOS/Linux), navigate to the folder where the file is saved, and type:
  • python hello_world.py (for Windows) or python3 hello_world.py (for macOS/Linux).
python hello_world.py

What Happens When You Run the Program?

Once you run the program, the output will be displayed on your screen as:

Hello, World!