\n",
"This tutorial is prepared by ACM/SIAM Student Chapter of King Abdullah University of Science and Technology (KAUST).\n",
"
\n",
"\n",
"Parts of this tutorial re-use
Scientific Python lectures by
Robert Johansson linsensed under
Creative Commons Attribution 3.0.\n",
"
\n",
"\n",
"Presented on 26 February, 2017.\n",
"
\n",
"\n",
"**Prerequisites:** *No prerequisites.*\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## What is Python?"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[Python](http://www.python.org/) is a **general-purpose**, high-level programming language.\n",
"\n",
"### The main features:\n",
"- **Clarity and simplicity.** The language is human-readable, quick and easy to learn, minimalisitc.\n",
"- **Expressiveness.** Achieve the same with fewer lines of code."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The Zen of Python, by Tim Peters\n",
"\n",
"Beautiful is better than ugly.\n",
"Explicit is better than implicit.\n",
"Simple is better than complex.\n",
"Complex is better than complicated.\n",
"Flat is better than nested.\n",
"Sparse is better than dense.\n",
"Readability counts.\n",
"Special cases aren't special enough to break the rules.\n",
"Although practicality beats purity.\n",
"Errors should never pass silently.\n",
"Unless explicitly silenced.\n",
"In the face of ambiguity, refuse the temptation to guess.\n",
"There should be one-- and preferably only one --obvious way to do it.\n",
"Although that way may not be obvious at first unless you're Dutch.\n",
"Now is better than never.\n",
"Although never is often better than *right* now.\n",
"If the implementation is hard to explain, it's a bad idea.\n",
"If the implementation is easy to explain, it may be a good idea.\n",
"Namespaces are one honking great idea -- let's do more of those!\n"
]
}
],
"source": [
"import this"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Quick technical details:\n",
"- **Dynamically typed.** No need to define the type of variables, function arguments or return types.\n",
"- **Automatic memory management.** No need to explicitly allocate memory. Python will take care of this. \n",
"- **Interpreted.** The code is **not compiled**, but interpreted and executed on the fly by the Python interpreter.\n",
"\n",
"### Advantages:\n",
"- Ease of programming.\n",
"- Minimal time on developing, debuggin, and maintain the projects.\n",
"- Powerful and well designed language:\n",
" - Modular, object-oriented, supports functional-style programming.\n",
"- Documentation tightly integrated with the code.\n",
"- Has a large, powerful, and well designed standard library, and numerous addiotional packages that can be installed literally in a few clicks.\n",
"\n",
"### Disadvantages:\n",
"* Slowness compared to *C/C++* or *Fortran* *(but there are ways to speed it up!)*.\n",
"\n",
"