Introduction to Python

To start

  • There are two popular versions of Python (2.7 and 3.5);

  • Ide \(\rightarrow\) Pycharm, Netbeans, Eclipse etc, I suggest Spyder (similar to Rstudio);

  • Jupyter Notebook \(\rightarrow\) web application to create and share documents (code, formulas, text, etc);

  • Anaconda \(\rightarrow\) contains R, Python, various IDE, Anaconda navigator (GUI), Anaconda Prompt and Jupyter Notebook.

Some tutorials

Some basic information

  • Python uses white space to identify code blocks (Avoid using tabs and prefer whitespaces) \(\rightarrow\) \(4\) spaces per indentation level;
  • No \(;\) at the end of each line;
  • No variable declaration as R;
  • assignment operator \(=\), i.e not <-.
# One line comment

"""
Two lines comment
"""

Some useful packages

Install packages

conda install -c conda-forge numpy
  • Anaconda Navigator \(\rightarrow\) enviroments \(\rightarrow\) search package

In both cases, it is useful to create an enviroments:

conda create -n yourenvname python=x.x anaconda
activate yourenvname

and then install packages into yourenvname.