Set Up: Browser, Python & VS Code
You do not need to install anything to begin. Every example in this course runs right here in your browser. But real programmers keep their programs as files on their own computer, so in this lesson you will also install Python and a free code editor called VS Code.
Do the browser part today. Do the installation part whenever you are ready, ideally before the lesson on Working with Files. It takes about twenty minutes.
Step 1: the Try-it editor on this site
Every example marked with a "Try it" button opens an editor. You can change the code and press "Run" as many times as you like. You cannot break anything: reloading the page brings the original example back.
Python examples run a real Python 3.14 inside your browser. JavaScript examples run in your browser's own JavaScript engine. Try both now:
print("Python is running in my browser")
print(365 * 24)Python is running in my browser 8760
console.log("JavaScript is running in my browser");
console.log(365 * 24);JavaScript is running in my browser 8760
Both programs print a message and then the number of hours in a year. Change 365 to 366 for a leap year and run them again.
Step 2: the browser console
Every desktop browser has developer tools with a console, a place where you can type JavaScript and see the answer straight away. Press F12 (or Ctrl+Shift+I on Windows and Linux, Cmd+Option+I on a Mac) and click the Console tab. Type a line and press Enter:
> 1299 * 3
3897
> "Pune".length
4The console is great for quick experiments. It is also where JavaScript shows its error messages, so you will use it a lot later.
Step 3: install Python
First check whether Python is already there. Open a terminal: the text window where you type commands. On Windows, search the Start menu for "Terminal" or "PowerShell". On a Mac, open "Terminal" from Applications, then Utilities. Type:
python --versionPython 3.15.0
If you see a version number starting with 3., you are ready. On a Mac or Linux, try python3 --version instead. If you get "not recognized" or "command not found", install Python:
- Windows: get the Python install manager from the Downloads page at python.org or from the Microsoft Store. It adds the
pycommand. Runpy install 3.15to install the latest version, andpy listto see what is installed. - macOS: download the macOS installer from python.org and run it. Then use
python3in the terminal. - Linux: Python 3 is almost always installed already; check with
python3 --version.
Any recent Python 3 version is fine for this course. Close the terminal and open a new one after installing, so it can find the new command.
Step 4: install VS Code
A code editor is a text editor made for programmers. It colours your code, warns you about mistakes and runs programs with one click. Visual Studio Code (VS Code) is free and works on Windows, Mac and Linux.
- Download VS Code from code.visualstudio.com and install it.
- Make a folder for your practice, for example
coding-practicein Documents. - In VS Code, choose File, then Open Folder, and pick that folder.
- Open the Extensions view (
Ctrl+Shift+X), search for "Python" and install the extension published by Microsoft. - Create a new file named
hello.pyand type this program:
name = "Farhan"
print("Hello from", name)
print("My computer can run Python!")Hello from Farhan My computer can run Python!
Save the file (Ctrl+S) and click the Run button (a triangle) at the top right. The output appears in the terminal panel at the bottom. You can also run it yourself in a terminal that is inside the same folder:
python hello.pyUse py hello.py on Windows or python3 hello.py on a Mac or Linux if plain python does not work.
Step 5 (optional): Node.js for JavaScript files
In a browser, JavaScript lives inside web pages. To run a JavaScript file directly, like a Python file, install Node.js from nodejs.org (choose the version marked LTS, which means long-term support). Check it with node --version. Then create hello.js:
const name = "Farhan";
console.log("Hello from", name);
console.log("My computer can run JavaScript!");Hello from Farhan My computer can run JavaScript!
Run it in the terminal with:
node hello.jsThe terminal in two minutes
You only need a few commands to start:
| Command | What it does |
|---|---|
cd coding-practice | Move into the folder named coding-practice |
cd .. | Move up one folder |
dir (Windows) or ls (Mac, Linux) | List the files in the current folder |
python hello.py | Run a Python file |
node hello.js | Run a JavaScript file with Node.js |
Common mistakes
- "python is not recognized". Python is not installed, or the terminal was opened before you installed it. Close it, open a new one, and try
pyon Windows. - Typing commands inside Python. If you see
>>>, you are inside Python's interactive mode, not the terminal. Typeexitand press Enter, then runpython hello.py. - Running from the wrong folder. "No such file" usually means the terminal is in a different folder. Use
cdto move to the folder that contains your file. - Forgetting to save. If your change does not appear when you run, press
Ctrl+Sfirst.
Key points
- You can learn the first part of this course entirely in the browser with the Try-it editor.
- The browser console (
F12) runs JavaScript one line at a time and shows errors. - Check Python with
python --version; on Windows the Python install manager gives you thepycommand. - VS Code with Microsoft's Python extension is a free editor that runs your files with one click.
- Node.js runs JavaScript files outside the browser with
node file.js.
Exercise
If you can, install Python and VS Code. Create a folder named coding-practice with a file about.py that prints your name on the first line and your city on the second line. Run it from the VS Code Run button and then from the terminal. If you cannot install anything yet, write the same program in the Try-it editor, and also write it in JavaScript.
Show solution
print("Isha")
print("Lucknow")cd coding-practice
python about.pyconsole.log("Isha");
console.log("Lucknow");The terminal must be inside coding-practice, the folder that contains about.py, otherwise Python reports that it cannot find the file.
Quick Quiz
1. Do you need to install anything to run this course's examples?
The Try-it editor runs Python and JavaScript in the browser; installation is only needed for working with your own files.
2. Which command checks the installed Python version?
python --version prints something like Python 3.15.0 (use python3 on Mac or Linux).
3. What does Node.js let you do?
Node.js is a JavaScript runtime that runs .js files from the terminal.
4. You see >>> and type python hello.py, and get an error. Why?
Leave interactive mode with exit, then run the command in the normal terminal.
Learn Intro to Programming with a mentor
Free lessons get you started. Our Python Programming training adds real projects and code reviews from working developers.
- Project-based learning
- Mentor code reviews
- Free counselling call
