To start your journey as a Python developer, you need to install Python into your system.
To do this, open up python.org/downloads From there, download the most recent version by clicking on the yellow button
Next, head over to your downloads folder and click the downloaded Python package to start the installation.
If you are on Windows, you are going to see a checkbox that says
Add Python x.x to PATH. Make sure to check this checkbox.
On Mac, just click through the installation wizard.
Once complete, you have successfully installed Python on your system.
But having Python installed is not enough for you to start writing code. You also need a code editor where you write your programs.
Install Code Editor for Python
Similar to using Word or Notepad to write documents, you need to use a code editor for writing Python programs.
In this guide, you will download Visual Studio Code.
Visual Studio Code or VSCode is one of the hottest code editors at the moment. You can use it to write programs in almost any programming language out there. Python is no exception.
Let’s install VSCode on your machine.
To do this, follow these 6 steps:
- To install VSCode, go to code.visualstudio.com, and click the blue download button.
- After the download has been completed, head over to your downloads folder.
- Double-click the VSCode installer file to install the VSCode editor.
- Ace through the installation wizard. If you are on Mac, drag and drop the VSCode icon to the Applications folder at the end of the setup wizard.
- Once the installation has been completed, open up a Visual Studio Code window.
- Now you have a code editor where you can write code.
Before writing your first Python program, you need to configure the VSCode code editor to recognize Python.
In your VSCode window, open up the extensions tab:
Write “Python” in the search bar.
Install the first search result (with 40m+ downloads).
After installing, you are all set.
Next, let’s write a simple Python program to verify that everything works as expected.
An Example Python Program with VSCode
Open up a VSCode editor window (if you already haven’t).
- Go to
File > New File
- A new file opens up. Go to
File > Save As...
- Name the file
example.pyand save it on your Desktop for example.
You have now successfully created your first Python file. You can now start writing code to this file to create your first Python program.
Step1. To create the simplest possible Python program, write the following code into your Python file in VSCode:
Step 2. Then click the “play button” at the top right corner of your VSCode editor.
Step 3. Look at the bottom of the code editor. It opens up a small command-line window. This window shows the output of your program. Now, it has some garbage text and then “Hello world” on a separate line. This “Hello world” is the output of your very first Python program!
Congrats, you have successfully created and run your first Python program!
If you for some reason do not see this output or have encountered errors along the way, please let me know in the comments section below.
Thanks for reading. I hope you enjoy it.