Session 14 – Introduction to Python

14.1 Welcome to Python! Why Python?

Python is relatively easy to learn compared to most programming languages and is vastly popular among both programmers and employers. Code written in Python is universal among operating systems; allowing code to be carried between Windows, Mac and Linux without the need to re-write the code.

Python code is quite minimalist compared to other languages, making reading and writing code quicker and easier. Even non-programmers are able to read Python code with little issue. Because there is less to type, it is subsequently easier to debug and maintain Python code.

Lastly, Python is highly desirable throughout many fields of work. Popular applications of Python include, but are not limited to: web development, machine learning, data science, and analytics. The possibilities with Python are further broadened by its ability to incorporate other languages with easy. Imagine building the foundation of code in Python and utilize other languages like R and Java in places where they exceed Python’s capabilities.

This Python section was adapted from techbeamers and learnpython.

14.2 Which Python should I install?

Python has releases dating to 1990 but it was first created in the 1980s. It has evolved over the past 40 years and big updates have greatly expanded Python’s utility and changed its syntax to become more user friendly. It is because of these big changes that we have a major divide between Python2 and Python3. Python2 includes any version conforming with the following structure: Python v2.x.x. Ideally you would install Python3 as it is the most recent version; however, there exists code that will only run on Python2 online. Python3 is not backwards compatible.

Long story short, download both recent versions of Python2 and Python3, but we will use only Python3 in this course. If you encounter a program that operates in Python2 you can always use that version you installed to run it.

We will install: Python v2.7.18 and Python v3.9.2.

14.3 Mac OS X Python Installations

Mac users may download python via its webpage: https://www.python.org/downloads/mac-osx/ Download both Python2 and Python3

Or

If you prefer to practice your command-line skills follow the steps below in terminal:

Install HomeBrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install Python

brew install python2
brew install python3

14.4 Windows Python Installations

Windows users may download python via its webpage. Then, download both Python2 and Python3.

14.5 Install an IDE, or integrated development environment

Let’s also download PyCharm IDE form here.