<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Python 101
This introduction is based heavily on the introduction notes found here
Step1:  Working in Python
Make sure you now type source activate python_workshop on UNIX based systems and activate python_workshop - this may not be necassary if you have nb_conda_kernels installed.
Python is an interpreted language and there is more than one interpreter we can use
Step2:  Containers
Lists
Step3:  Loops
Step4:  Dictionaries
Step5:  There are other containers too, but we won't cover them here. Most useful are probably sets and named tuples.
Logic
<ASSISTANT_TASK:>
Python Code:
import this
Explanation: Python 101
This introduction is based heavily on the introduction notes found here: https://github.com/scipy-lectures/scipy-lecture-notes
The (climate) scientists needs
To get, potentially very large, datasets from simulation, observation, or experiment
To manipulate and process it
To visualize results, quickly to understand, but also with high quality figures, for reports or publications.
Why Python
I've used pretty much every programming language you can think of... MatLab, IDL, Fortran, C++, C#, Java,... But Python, for me anyway, is the best of the lot. It's flexible, fast, easy to read and portable across all sorts of machines and architectures.
Batteries included Rich collection of already existing bricks of classic numerical methods, plotting or data processing tools. 
Easy to learn Most scientists are not payed as programmers, neither have they been trained so. 
Easy communication To keep code alive within a lab or a company it should be as readable as a book by collaborators, students, or maybe customers. 
Efficient code Python numerical modules are computationally efficient. 
Universal Python is a language used for many different problems. 
Let's compare a bit more specifically against some other languages we might use:
Compiled languages: C, C++, Fortran...
<tr>
<th>Pros</th>
<td>
   <ul>
    <li>Very fast. For heavy computations, it's difficult to outperform these languages.</li>
   </ul>
 </td>
</tr>
<tr>
<th>Cons</th>
<td>
   <ul>
    <li>Painful usage: no interactivity during development, mandatory compilation steps, verbose syntax, manual memory management. These are **difficult languages** for non programmers.</li>
   </ul>
</td>
</tr>
Matlab
<tr>
<th>Pros</th>
<td>
   <ul>
    <li>Very rich collection of fast libraries with numerous algorithms, for many different domains.</li>
    <li>Pleasant development environment: comprehensive and help, integrated editor, etc.</li>
    <li>Commercial support is available.</li>
   </ul>
 </td>
</tr>
<tr>
<th>Cons</th>
<td>
   <ul>
    <li>Base language is quite poor and can become restrictive for advanced users.</li>
    <li>Not free.</li>
   </ul>
</td>
</tr>
Julia
<tr>
<th>Pros</th>
<td>
   <ul>
    <li>Fast code, yet interactive and simple.</li>
    <li>Easily connects to Python or C.</li>
   </ul>
 </td>
</tr>
<tr>
<th>Cons</th>
<td>
   <ul>
    <li>Ecosystem limited to numerical computing.</li>
    <li>Still young.</li>
   </ul>
</td>
</tr>
Other scripting languages: Scilab, Octave, R, IDL, etc.
<tr>
<th>Pros</th>
<td>
   <ul>
    <li>Open-source, free, or at least cheaper than Matlab.</li>
    <li>Some features can be very advanced (statistics in R, etc.)</li>
   </ul>
 </td>
</tr>
<tr>
<th>Cons</th>
<td>
   <ul>
    <li>Fewer available algorithms than in Matlab, and the language is not more advanced.</li>
    <li>Some software are dedicated to one domain. </li>
   </ul>
</td>
</tr>
Python
<tr>
<th>Pros</th>
<td>
   <ul>
    <li>Very rich scientific computing libraries (amonst others - web server, serial port access, etc.).</li>
    <li>Well thought out language, allowing to write very readable and well structured code: we “code what we think”.</li>
    <li>Free and open-source software, widely spread, with a vibrant community.</li>
    <li>A variety of powerful environments to work in, such as IPython, Spyder, Jupyter notebooks, Pycharm</li>
   </ul>
 </td>
</tr>
<tr>
<th>Cons</th>
<td>
   <ul>
    <li>Not all the algorithms that can be found in more specialized software or toolboxes.</li>
   </ul>
</td>
</tr>
The scientific Python ecosystem
Unlike Matlab, or R, Python does not come with a pre-bundled set of modules for scientific computing. Below are the basic building blocks that can be combined to obtain a scientific computing environment:
Core Python
The language: flow control, data types (string, int), data collections (lists, dictionaries), etc.
Modules of the standard library: string processing, file management, simple network protocols.
Core numeric libraries
Numpy - Numerical array types and operations
Matplotlib - General plotting routines modelled on MatLab
SciPy - Fast linear algebra and optimisation routines
Domain specific libraries
Iris - For working with model data
CIS - For working with observational data and collocation
Pandas - Extensive (time)-series analysis routines
sci-kit-learn - Machine learning algorithms
...
The Zen of Python
End of explanation
# The obligatory hello world...
print("Hello world!")
an_integer = 9
a_float = 2.5
a_string = "blah"
a_complex_number = 2 + 2j
an_integer / 4
def say_hello(name):
    print("Hello {}!".format(name))
say_hello("world")
def say_hello(name, indent=0):
    padding = " "*indent
    print(padding + "Hello {}!".format(name))
say_hello("Duncan", 4)
say_hello(3, 4)
Explanation: Working in Python
Make sure you now type source activate python_workshop on UNIX based systems and activate python_workshop - this may not be necassary if you have nb_conda_kernels installed.
Python is an interpreted language and there is more than one interpreter we can use:
 * python - The basic built-in interpreter
 * iPython - A more feature rich interpreter with tab-completion, shell access and inline plots
 * Jupyter (iPython) notebooks - A web based iPython interpreter with markdown (and $\LaTeX$!) support
For this course we will be using the iPython notebooks - these are great for working interactively and storing the results, as well the code and any notes we might want to make. For script development you can use a basic text editor or an IDE (or anything in between), we'll be exploring PyCharm later in the course
Basic syntax
End of explanation
assorted_stuff = ["dog", 3, 2.34, "cat"]
assorted_stuff[0]
assorted_stuff[:-1]
assorted_stuff[::-1]
assorted_stuff.sort()
print(assorted_stuff)
Explanation: Containers
Lists
End of explanation
for item in assorted_stuff:
    print(item)
Explanation: Loops
End of explanation
# A collection of key-value pairs
simple_lookup = {"red": 2, "green": 12, "blue": 7}
print(simple_lookup["red"])
print(simple_lookup["yellow"])
print(simple_lookup.get("yellow", 0))
simple_lookup["orange"] = 15
simple_lookup[4] = "brown"
print(simple_lookup[4])
Explanation: Dictionaries
End of explanation
# Simple conditional statements
variable = 0.95
if variable > 0.9:
    print("On")
if variable > 0.9:
    print("On")
elif variable < 0.1:
    print("Off")
elif 0.4 < variable < 0.6:
    print("Intermediate")
else:
    print("Unknown")
switch = "On" if abs(variable-1.0) < 0.1 else "Off"
print(switch)
Explanation: There are other containers too, but we won't cover them here. Most useful are probably sets and named tuples.
Logic
End of explanation
<END_TASK>