Python Basics Series – Part 2

Intro

The next step in becoming proficient with Python is to install an Integrated Development Environment or IDE. IDE’s are applications that allow programmers to develop code efficiently and come with tons of features and addon’s.

Download

The IDE that I suggest is Microsoft Visual Studio and it can be found here https://visualstudio.microsoft.com/downloads/ the Community version is free!

Selecting the Community version will begin your download and once complete you can select the executable from your browser (Chrome depicted below)

Install

Selecting the download and choosing Open will begin the guided installation process. Select Python development from the Workloads list when prompted and click Install.

Next, launch Visual Studio Community 2022 and sign in or create an account when prompted.

Code

Continue to follow the onscreen prompts and when presented with the next screen choos Create a new project.

At the next prompt select Python Application and Next.

The next window that will appear will look something similar to this.

Let’s learn a little bit about how to structure Python code next. The first thing that most programmers start their project with is a comment. If you remember from https://cybersecsyndicate.com/hello-world/ our Python Basics Series – Part 1 is that comments start with a “#” and provide some useful insight into the project or code.

The next section of code in a typical Python application contains our import statements. Import statements allow you to bring in prebuilt code modules from other libraries. These modules can extend the functionality of your program quickly and easily. Let’s import a few useful modules:

The next bit of code is just an example of how we could use these two modules. If you don’t understand this code yet don’t worry we will continue to expand our knowledge about Python in the coming modules!

Next, let’s execute our code using the Start button at the top of Visual Studio.

After clicking the Start button you will notice that a new Python shell opens and our code is running! Enter a guess for the randomly generated number and see if you guess correctly! The time statement simply introduces a bit of delay before continuing execution of the Python code below it.

Congratulations you have now installed Python, wrote a hello world program, installed an IDE (Visual Studio Code), and written your second application! Join us next time as we dive deeper into Python and coding now that we have an environment setup.

Scroll to Top