Your First Python Program: "Hello, World"
It’s a long-standing tradition in programming that your first program simply displays a greeting message like “Hello, World.”
This is an excellent way to get familiar with the basic workflow of writing, running, and debugging code.
1. Create a Python File
- Open your preferred code editor or IDE (for example, VS Code, PyCharm, or even Notepad).
- Create a new file and save it with the
.pyextension, for example:hello_world.py.
2. Write the Code
Inside your file, write the following code:
print("Hello, World")
````
This simple program uses the `print` function to display the message “Hello, World” on the screen.
---
## **3. Run the Program**
1. Open a terminal or command prompt.
2. Navigate to the folder where you saved your file. For example, if the file is in the **Documents** folder:
```bash
cd Documents
- Run the program by typing:
python hello_world.py
or, if your system requires python3:
python3 hello_world.py
4. See the Result
If everything is set up correctly, you should see the following in your terminal:
Hello, World
Code Explanation
print: A built-in Python function that sends text to the standard output (usually the screen)."Hello, World": A text string (or string literal) that is displayed as output.