Here is how to configure Task Runner in Visual Studio Code to run a .py file.
In your console, press Ctrl + Shift + P (Windows) or Cmd + Shift + P (Apple). This brings up a search box where you search for "Configure Task Runner"

If this is the first time you open the "Task: Configure Task Runner", you need to select "other" at the bottom of the next selection list.
This will bring up the properties which you can then change to suit your preference. In this case you want to change the following properties;
- Change the Command property from
"tsc"(TypeScript) to"Python" - Change showOutput from
"silent"to"Always" - Change
args(Arguments) from["Helloworld.ts"]to["${file}"](filename) - Delete the last property
problemMatcher - Save the changes made

You can now open your .py file and run it nicely with the shortcut Ctrl + Shift + B (Windows) or Cmd + Shift + B (Apple).
Answer from python_starter on Stack OverflowHow to set up python on vs code
How to execute Python code from within Visual Studio Code - Stack Overflow
Python in Visual Studio Code โ May 2022 Release
Microsoft announces the May 2022 release of the Python and Jupyter Extensions for Visual Studio Code introducing three new extensions: Black, isort, and Jupyter Powertoys.
More on reddit.comAny reason I should use PyCharm over Visual Studio Code?
How do I set up VSCode to format Python code on save using Black?
To set up VSCode to format Python code using Black, go to Settings and search for "Python formatting provider", select "black", and ensure "Editor: Format On Save" is enabled.
How can I configure VSCode to use a specific Python interpreter for different projects?
You can specify a Python interpreter for each project by selecting the interpreter in the Command Palette (Ctrl+Shift+P) using the command "Python: Select Interpreter". This setting is saved in the project's .vscode/settings.json.
What are some recommended extensions for Python data visualization in VSCode?
For data visualization, extensions like Plotly for Visual Studio Code and Jupyter Notebook Renderers can enhance your experience by providing interactive plots and rendering capabilities.
Hi. I am new to Programming and I decided to start my learning journey with cs50 python. Sadly I live in a war zone and I don't always have access to internet. I cannot use the online interface for the course everyday so I want to be able to work offline sometimes. I installed vs code but it always tell me that python is not present. I don't really understand the tutorials I saw online and I would appreciate any help
Here is how to configure Task Runner in Visual Studio Code to run a .py file.
In your console, press Ctrl + Shift + P (Windows) or Cmd + Shift + P (Apple). This brings up a search box where you search for "Configure Task Runner"

If this is the first time you open the "Task: Configure Task Runner", you need to select "other" at the bottom of the next selection list.
This will bring up the properties which you can then change to suit your preference. In this case you want to change the following properties;
- Change the Command property from
"tsc"(TypeScript) to"Python" - Change showOutput from
"silent"to"Always" - Change
args(Arguments) from["Helloworld.ts"]to["${file}"](filename) - Delete the last property
problemMatcher - Save the changes made

You can now open your .py file and run it nicely with the shortcut Ctrl + Shift + B (Windows) or Cmd + Shift + B (Apple).
All these answers are obsolete now.
Currently you have to:
- install the Python language extension (and Python, obviously)
- open folder (important!), open any Python file inside that folder
- switch to debug "tab"(?) and click on the gearbox (with hint 'Configure of Fix 'launch.json'')
- save the opened launch.json file (it's placed in .vscode subdirectory in the folder opened in step #2)
- finally, click the green triangle or hit F5
No additional extensions or manual launch.json editing is required now.