Introduction
Using the Python programming language can be a fun and rewarding process even if you are intimidated by coding or scripting. Python is also one of the most popular languages used in Cybersecurity today so it is immensely valuable to learn.
This series is meant to simplify and demystify your journey into learning Python. You will get step by step instructions on how to write your first Python program and I will teach you the skills you need to take you from zero knowledge about Python to a comfortable familiarity from which you can build on.
Part 1 of this learning Python series introduces you to how where to find Python, how to install Python, and finally how you can write your first program in Python.
Download
First, let’s get Python downloaded you can start by visiting the downloads page at the official site Python.org (https://www.python.org/downloads/). Pages often change but at the time of this writing near the top of the page you should see something similar to this.
Clicking the Download Python 3.11.1 button will download the latest version of Python (the latest version may differ from the version you see at the time of this writing). Once downloaded Chrome users will see something similar to this. (Browsers handle downloads differently)
Install
Opening this file will start the guided Python setup.
Following the onscreen prompts using the selected default settings is generally the safest way for anyone new to Python to start.
Running Python
Once completed clicking the Windows icon (Start Menu) will allow us to type Python into the search box will quickly bring up the Python executable for you.
Selecting this executable will open up the Python interpreter. Congratulations it’s time to get started with your first program in Python!
The very first program that most people start with in any language is so simple! It’s called “Hello World!” and first I’ll show you how to do this from the interpreter. Simply type the following and press ENTER:
So easy! The interpreter allows us to interact with Python live via a command prompt style interface. But what if we wanted to save this program forever? Let’s create a new folder on our Desktop for our python code.
Inside of this folder we will create a new text file called “hello_world.py”. If you are prompted that changing the extension of this file may cause instability don’t worry and select YES. You will notice that after naming the file that it becomes a Python File.
Next, let’s open this file and edit it. Right click the file and select “Open With >” and find your favorite text editor. I use Notepad++ but the default windows notepad will work just fine as well. We will type three lines of code and that is it!
The first line of code is called a comment. Comments must start with the # symbol and they can be your best friend providing useful reminders of what the following code is intended for. The next line of code is our already familiar print statement that will print whatever is inside the parenthesis to the screen. Finally, the last line of code provides us with a way to keep the shell from terminating. The input command is used to accept user input to allow the subsequent code to perform some type of action. We are using this pause the execution of the program so that we can see what is printed to the screen without Python automatically closing the shell that is created before we can view it.
Now to run our code but first, save the file that we created. Next, double click our “hello_world.py” file in our “Python Code” folder. When you do this you will see the following:
Congratulations! You have taken the first few steps to becoming a successful Python scripter! Check back for Part 2 in this series for learning Python basics!