Python: Getting Started

In the era of big data and data science, it is a must to have Python programming capability. I started learning Python two years ago when I took the Web Science offered by Dr. Michael Nelson during my master’s at ODU. In my personal opinion, I found that Python is a very straightforward language and very intuitive to learn. Python is also the most-seek programming capability in the data science job market. So, if you aim for employment opportunities in data science field, you should consider learning Python and R. We’ll talk about R in another blog post.

What is Python?

Python is an interpreted high-level, versatile, and popular language for general-purpose programming. It’s great a great language because it is concise and easy to read and can be used for everything from web development to software development and scientific applications.

Pros?

  1. free
  2. general purpose –> you can build anything
  3. many packages

Cons?

  1. When it comes to the performance, Python is often considered slower than C. Python provides a powerful platform for working with data, but often the most straightforward data analysis can be painfully slow. When used effectively, though, Python can be as fast as compiled languages like C [reference].

How to start using python?

First, you have to install Python first, of course. If you are using Ubuntu 16.04, you don’t need to worry because Ubuntu 16.04 comes with both Python 2.7 and Python 3.5 by default (ref: ubuntuhandbook.org). In this post, I am gonna show you how to install Python 3.6.1 in Ubuntu 16 by typing the following commands:

  1. adding Personal Package Archive (PPA) and check updates:
  2. install the python:  sudo apt-get install python3.6
  3. to start using python, type in the terminal:
    1. python  –> if you use python 2.7
    2. python3  –> if you use python 3.5
    3. python3.6  –> if you use python 3.6

If you are using Windows, well, that’s a different story. First you have to download the Python executable file from python.org. Then, install it as easy as double-clicking the .exe file.

Python Editor and IDE?

Now, that you have Python up and running in your machine. Next, you have to think about how you’d like to start coding. Basically, you can always code inside the terminal. But, I personally found this impractical and it’s better to use any Python Editor you can download for free from the internet. Some of the text editors that I have ever used are:

  1. Editor: notepad, atom, sublime.
    The complete list of Python Editor can be seen on wiki.python.org.
  2. IDE.
    There are so many Python IDEs available on the internet. But, I personally have ever only used Pycharm.

    1. pycharm.
      1. symbol vocabularies: https://www.jetbrains.com/help/pycharm/symbols.html , some of them:
        1. c = class
        2. m = method
        3. F = function
        4. f = field
        5. v = variable
      2. method vs function:
        1. method –> class function, has parameter ‘self’
        2. function –> non-class function, has no parameter ‘self’
      3. field vs variable
        1. variable = non-class variable.
        2. field = class variable –> definition is preceded by ‘self._’. Example:

I personally recommend using sublime or pycharm.

Installing Libraries:

Python is powerful because of its wide and complete supporting libraries. So, after installing python and its editor, you also need to cosider installing libraries that migh be needed for the coding part.

From: https://pip.pypa.io/en/stable/user_guide/#installing-packages

If you are really new to Python, it’s good to have some code inspirations to get started. I suggest enrolling in some free courses from Coursera or datacamp. If a friend of yours is a good Python programmer, you can also fork their github and start tinkering with the code. If you feel really lost and totally blank, you can try the example from python.org.

Cheatsheet:

  • Finding a type of variable –> use type()
  • change type of something to string –> str()
  • math symbol: +, -, *, /, %, //
    • //  = floor division –> round down to nearest whole number.
  • In Python, the semicolon symbol ;  is used to place commands on the same line.
    Example:

     

Leave a Reply

Your email address will not be published. Required fields are marked *

Show Buttons
Hide Buttons