First, create a project folder.
Open the command prompt on Windows and go to that folder location. Now type code .
VS Code will be opened in that folder.
How to create a virtual environment on vs code using command prompt.
Type python -m venv .venv. Here last .venv is the folder name of the virtual environment. Now activate the virtual environment by running the activate file. The activate file is located in the Scripts folder under the .venv folder. After running the activate file you will find that the virtual environment is running as follows.