print('hello world')

"""
Explanation: Basic Python Explorations
This is our first IPython nootebook, which we are going to use to explore the very basics of Python programming,
End of explanation
"""


# This is an online comment: Python3
print('hello world')

# Python2:
print 'hello world'

"""
Explanation: As some you were asking about differences between Python2 and Python3, here is an example:
End of explanation
"""


1 * 1.0
a = 3.0
type(a)

b = 3 > 5
type(b)

a = int(a)
type(a)

"""
Explanation: More broadly speaking, some function interfaces (here print function) change. We will encounter other examples as we move along. More information regarding this issue is available at https://wiki.python.org/moin/Python2orPython3.
Basic Types
We now look at different types of objects that Python offers: floats, intergers, lists, dictionaries, etc.
End of explanation
"""


# Different between Python2 and Python3
3 / 2


"""
Explanation: What about integer division?
End of explanation
"""


L = ['red', 'blue', 'green', 'black', 'white']

L[3], L[-2], L[3:], L[3:4]

"""
Explanation: Let us now turn to containers: lists, strings, etc.
End of explanation
"""


L[1] = 'yellow'

"""
Explanation: Lists are mutable objects, i.e. they can be changed.
End of explanation
"""


G = L
L[1] = 'blue'
L, G

G = L[:]
L[1] = 'yellow'
L, G

"""
Explanation: There is an important distinction between independent copies and references to objects.
End of explanation
"""


L.append('pink')
print(L)
L.pop()
print(L)

"""
Explanation: How to work with lists, or objects more generally?
End of explanation
"""


T = 'white', 'black', 'yellow'
T

T[1] = 'brown'

"""
Explanation: Now we turn to tuples, which are immutable objects.
End of explanation
"""


print(T)
del T
print(T)

"""
Explanation: As you asked, here is one way to delete objects.
End of explanation
"""


tel = {'Yike': 4546456, 'Philipp': 773456454}
tel

tel[1]

# What is Yike's telephone number?
tel['Yike']

# How do we add Adam?
tel['Adam'] = 7745464
tel

# What keys are defined in our dictionary so far?
tel.keys()

# Yike has a new telephone number.
tel['Yike'] = 77378797

"""
Explanation: Now, let us turn to dictionaries, which are tables that map keys to values.
End of explanation
"""


a, b = 1, 5

if a == 1:
    print(1)
elif a == 2:
    print(2)
else:
    if b == 5:   
        print('A lot')
    
# Note the indentation.

for key_ in tel.keys():
    print(key_, tel[key_])

"""
Explanation: Control Flow
End of explanation
"""


def return_phone_number(book, name = 'Philipp'):
    ''' This unction returns the telephone nummber for the requested name.
    '''
    # Check inputs.
    assert (isinstance(name, str)), 'The requested name needs to be a string object.'
    assert (name in ['Yike', 'Philipp', 'Adam'])
    
    return book[name]

return_phone_number(tel)
return_phone_number(tel, 'Philipp')
return_phone_number(tel, 'Yike')
return_phone_number(tel, 'Peter')

"""
Explanation: Functions
It is important to distinguish between required, optional, and default arguments.
End of explanation
"""


import urllib; from IPython.core.display import HTML
HTML(urllib.urlopen('http://bit.ly/1Ki3iXw').read())

"""
Explanation: Next Steps
Python Environment

Python Science Stacks
Quantitative Economics

Virtual Machines

Data Science Toolbox
VM Depot
VagrantCloud

Dual Boot

Mac
Windows

Miscellaneous

Keyboard Shortcuts
Markdown Tutorial 

Formatting
End of explanation
"""


