Python basic concepts

Variables and functions

  • variables or objects are containers for storing values with a name
  • functions or modules are scripts with Python code that perform a certain action

Creating a variable

Variables are created by what is called an assignment and = is used as an assignment operator.

v = 4

You assign a value to a variable. Write the value at the right side and the name of the variable at the left side.

Functions and Packages

Functions are organized into packages, collections of related functions, for instance matplotlib is a package with functions for plotting, pandas is a package with functions for data analysis, similar to R. Packages are also called libraries. They are essentially a folder on your computer that contain a bunch of Python scripts.

Installing a package is not enough to use it. You have to import it into the memory of your computer where Python can use it.