Python - Chapter 1

Getting Started

Introduction to Python

Python was developed in the late 1980s, by Guido van Rossum. Python 1.0 was released in 1994, followed by 2.0 in 2000. In December 2008, Python 3.0 was released. Despite the similarities between version 2.x and 3.x, they remain quite incompatible. Python 2.0 has an official end of support in the year 2020. For that reason and a long-term vision in mind, we will be using Python 3.x throughout this course.

Why Python?

A question many would be asking is why Python, out of the multitude of languages we can choose, starting from the good old Java, C++, Ruby, Golang, and the new favourite Swift?

Python is undoubtedly one of the most popular programming languages. According to the 2018 Stack Overflow developer survey, Python has a “solid claim to be the fastest-growing” programming language. Not only that, Python is one of the most loved languages with 68.0% of respondents in the survey loving it.

Apart from the popularity and love Python gets, we chose Python, simply because its simple. It sports a clean code structure, making it really easy to read.

The only factor which might irk some will be that it is whitespace and indentation based. Nevertheless, it is rather hard for one to hate Python (unless you have Ophidiophobia - Wikipedia).

Setting up Python

There are already a million resources online on setting up Python. We are not going to rewrite them point by point again.

In general, you need to first check if you already have Python installed. If yes, make sure it is Python 3.6.x or above. If not, go to Download Python | Python.org to download and install Python.

Alternatively, you can install the Anaconda distribution available at Downloads - Anaconda for all platforms.

Command Line Basics

Before we dive into the deep, let’s take a small crash course on command line basics.

Windows

On Windows, open the command prompt window.

  • To find the current directory you are in, type cd. This will return something like C:\Users\Jack.
  • To list all the files and folders that are in the present directory, type dir .
  • To go into a folder, type cd <folder_name>, replacing <folder_name> with the actual folder you want to navigate into.
  • To move one level up from the current directory, type cd ...

macOS/Linux

On macOS or Linux, open the terminal.

  • To find the current directory you are in, type pwd. This should return something like /Users/Jack.
  • To list all the files and folders that are in the present directory, type ls.
  • To go into a folder, type cd <folder_name>, replacing <folder_name> with the actual folder you want to navigate into.
  • To move one level up from the current directory, type cd ...

Setting Up a Coding Environment

Before we start on the code, you need something to code in. The recommended editor here is Visual Studio Code. It is a free and open-source editor from Microsoft. Download and install it.

If you already have a preferred editor or Integrated Development Environment (IDE), feel free to use them. Other popular editors are: Sublime Text(Windows/macOS), TextMate (macOS), Notepad++ (Windows), Atom (Windows/macOS).

To run a script, you simply need to save the file ending with a .py extension. Open up the terminal, and navigate to the directory you saved your file in. Type python3 <file_name>.py and hit Enter. This should run your Python file.

The alternative to having an editor, is to use the Jupyter notebook which allows you to run the code in-line. We highly recommend this for all beginners. The instructions to set up Jupyter are available at Project Jupyter.

Ultimately, the choice is up to your preference.

Some Other Stuff (SoS)

If you are ever stuck, feel free to reach out to the Right from Basics team at hello@rightfrombasics.com, but only after you have Googled the problem.

“Googling” is a skill you need to earn and we expect you to help yourself before we do. Most of the problems you are facing are likely faced by many others. Many would have asked their questions online and solutions would have been contributed by others. An example of such an excellent platform you will soon be friends with is Stack Overflow. Use these resources first.

Please do not get us wrong. We are here to help, but we want you to be responsible for your own learning. But, if ever you still feel lost and need help, just ping us. :)

Help will always be given to those who ask for it.

Dumbledore, Harry Potter

comments powered by Disqus