Create and Run Python Project

To create and run a Python program, you must have Python , and a Python Development IDE such as Visual Studio Code installed on your computer. If you have not installed them yet then follow this guide to install them first.

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

  1. Open a terminal and create a folder with your project name using the command as shown in the example below:
        mkdir my_first_project
  3. Launch the Visual Studio Code.
  4. Add your project folder to the Visual Studio Code Explorer:
    • File > Add Folder to Workspace and add the project folder into the IDE.
  5. Create a Python file (A Python file has .py extension):
    • After your project is loaded in the Visual Studio Code Explorer, right-click on the project folder and from the toolbar select New File and type as your file name.
  6. Inside the file add the code given below:
        print("Hello World!")
  8. Next to run the code, right-click on the file 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!

    Note: You can also run a python program from the command prompt or terminal. Simply go the location where your Python file is and execute the command as shown in the example below:

        cd my_first_project