Beginning Python 3

In this series of plogs, I will be sharing my journey of learning Python.

What are my motivations behind deciding to learn Python?

  • I plan to build web apps, so I was looking for a language which has a mature ecosystem around it. Coming from a Java and PHP background, Python seemed attractive.
  • A little later, I plan on getting into Machine Learning, and the most popular language in the industry seems to be Python. It’s actually Python 2.7 as of writing this, but Python 3 support is growing. Oh, I did not mention it, but this plog series is going to focus on Python 3 only.
  • Python can be used for web scraping with ease, which is of great interest to me.
  • It is respected among the hacker community. Just to be clear, hacker means an expert in their field, not the negative association that is triggered more often than not.

Reading the above list, many languages can technically fit into those criteria, except the Machine Learning part.

A quick glance of Python:

  • High level
  • Interpreted
  • Dynamic typing system
  • Automatic garbage collection
  • Supports multiple programming paradigms, such as object oriented, functional and imperitive
  • Code readablity, which is a nice change coming from Java and PHP.

I am running Ubuntu 16.04, which has Python 2.7.12 and Python 3.5.2 pre-installed. If you are running a different OS, check this link to setup and use Python.

The Python interpreter can be started, by typing the following in the terminal:

python3

The Python 3 interpreter is running, where I can type in Python code and have it execute immediately.

The obligatory Hello World program:

print('Hello World')
Hello World

Hello world is displayed in the terminal.

Another way of running programs is by saving the code into a file and running it with python.

touch hello.py
gedit hello.py
#type the program
python3 hello.py
#output
Hello World

Source code is available here.

Resources:

  1. Wikipedia
  2. Python 3 official docs