{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n\nIntroduction to Python\n======================\n\n`Python `_ is a modern general-purpose object-oriented\nhigh-level programming language. First make sure you have a working Python\nenvironment and dependencies (see `install_python_and_mne_python`). If you\nare completely new to Python, don't worry, it's just like any other programming\nlanguage, only easier. Here are a few great resources to get you started:\n\n* `SciPy lectures `_\n* `Learn X in Y minutes: Python `_\n* `NumPy for MATLAB users `_\n\nWe highly recommend watching the SciPy videos and reading through these sites\nto get a sense of how scientific computing is done in Python.\n\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here are few important points to familiarize yourself with Python. First,\neverything is dynamically typed. There is no need to declare and initialize\ndata structures or variables separately.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "a = 3\nprint(type(a))\nb = [1, 2.5, 'This is a string']\nprint(type(b))\nc = 'Hello world!'\nprint(type(c))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Second, if you have a MATLAB background remember that indexing in Python\nstarts from zero (and is done with square brackets):\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "a = [1, 2, 3, 4]\nprint('This is the zeroth value in the list: {}'.format(a[0]))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Finally, often there is no need to reinvent the wheel. SciPy and NumPy are\nbattle-hardened libraries that offer a vast variety of functions for most\nneeds. Consult the documentation and remember that you can always ask the\nIPython interpreter for help with a question mark at the beginning or end of\na function:\n\n >>> import numpy as np\n >>> np.arange?\n\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.5" } }, "nbformat": 4, "nbformat_minor": 0 }