In this Python Beginner Tutorial, we will start with the basics of how to install and set up Python for Windows 10. We will also take a look at the interactive prompt of Python, as well as creating and running our first script. Let’s get started.
Table of Contents
- Windows 10 computer
- Command prompt (comes with windows by default)
Install Python on Windows 10
Installation of Python on the Windows 10 operating system is very straightforward. It’s just a matter of downloading the installer from Python website and running it on your windows computer.
First of all, we can check whether our computer has the python installed by running below command on the windows command line.
If you’re getting something similar to ‘python’ is not recognized as an internal or external command, operable program or batch file. Then that means python is not installed in your windows machine.
Here is the step by step guide on how to install Python on Windows.
- Open your favourite web browser and go to the official python website. Then download the latest version of Python.
Note: Python website will automatically detect your operating system. Since I’m on a Windows Computer, it will prompt me to download the executable file.
- The downloaded executable file typically located in the Downloads folder.
- Double click on the executable file. Installation Python will begin now. Select the default location for download.
- Make sure to check the “Add Python 3.8 to Path” option. – so that you won’t need to add the path to the Windows System variables manually. The benefit is you can run python commands within the windows command line.
- Within a few seconds, python will install in your windows computer.
- After installation finished, then hit the close button.
- To make sure our installation process completed, open up the windows command line and type below command.
If you get the python with its version, that means you’ve successfully installed the latest version of python on your windows machine.
Working with Interactive prompt
All right, you have already install and setup the Python on your windows 10 computer. Let’s see how can we write some basic Python scripts.
When we installed Python, it gives us “interactive prompt”. To access it open up your command line and type
The interactive prompt allows us to write one line of python code at a time. For example:- we can print “hello world” to the console by just typing
print('hello world') function.
This prompt is useful when we are testing Python commands, but in real-world applications, there are thousands of code lines in multiple python files. Such that each Python file contains multiple lines of codes.
To create such kind of Python script we need a text editor. When we downloaded the Python, it came with a default editor called “IDLE”.
Let’s open the IDLE application. Just search on the windows search bar to open the IDLE program. By default IDLE also an interactive prompt, meaning we can execute one line of code.
Working with the IDLE editor
To create a new file, go to File -> New File or use the shortcut keys of
N. Now we can code multiple lines of codes and form an executable Python script.
For example: – let’s print the Hello World to the console. For that use the
print() function. Inside the parentheses add a
Now let’s save the file which we have edited.
For that go to File -> Save or use the shortcut keys of
s. Then give it a valid name and location to be saved. Let’s run our script. Open up your windows command line and enter the python command with the name of the file we’ve saved. After executing the above command, our python script will run. “Hello, world” should be printed out to the console.
Even Though you could use default IDLE editor for writing python scripts, Most software professionals use some text editor or IDE.
Below are some of the best text editors and IDE’s for python application development.
- VS code
- Atom Text Editor
- Sublime Text
- PyCharm IDE
In this tutorial, you’ve learned about how to install and setup Python on Windows 10 computer. If you are using old versions of Windows, this guide might differ slightly but will apply most of the things I mentioned above. We also learn how to write your first python program using the command line and default python IDLE editor. Now you’ve set up python on your windows machine and ready to start writing some code.