Creating a Python Project

To create a Python project and run a Python program, you must have Python installed on your computer. You may also find it beneficial to install a Python code editor, such as Visual Studio Code, to streamline project development. If you haven't already, I recommend following this guide for installation.

Follow the steps below to create and run a Python project:

  1. Open a terminal and create a folder with your project name using the command as shown in the example below:
  2. mkdir my_project
  3. Launch the Visual Studio Code.
  4. Add your project folder to the Visual Studio Code Explorer: Go to File > Add Folder to Workspace and add the project folder into the IDE.
  5. After loading your project in the Visual Studio Code Explorer, right-click on the project folder. From the toolbar, select New File and enter a filename of your choice (e.g., main.py). A Python file has a .py extension.
  6. Inside the file, add your code. Here's a simple example that prints "Hello, World!" in the console:
  7. print("Hello World!")
  8. Next, to run the code, right-click on your file (e.g,. main.py) and from the toolbar options, select Run Python File in Terminal. In the IDE console, you will see the output as shown below:
  9. Hello World!

    You can also run a Python file from the command prompt or terminal. Simply navigate to the directory where your Python file is located and execute the command as shown in the example below:

    cd my_project
    python your_file.py