In [1]:
print("test")
test
In [2]:
import numpy
In [4]:
numpy.loadtxt(fname='data/inflammation-01.csv', delimiter=',')
Out[4]:
array([[ 0.,  0.,  1., ...,  3.,  0.,  0.],
       [ 0.,  1.,  2., ...,  1.,  0.,  1.],
       [ 0.,  1.,  1., ...,  2.,  1.,  1.],
       ..., 
       [ 0.,  1.,  1., ...,  1.,  1.,  1.],
       [ 0.,  0.,  0., ...,  0.,  2.,  0.],
       [ 0.,  0.,  1., ...,  1.,  1.,  0.]])
In [5]:
weight_kg = 55
In [6]:
print(weight_kg)
55
In [7]:
print('weight in pounds:', 2.2 * weight_kg)
weight in pounds: 121.00000000000001
In [8]:
weight_kg = 57.5
In [9]:
print('weight in kilograms is now:', weight_kg)
weight in kilograms is now: 57.5
In [10]:
weight_lb = 2.2 * weight_kg
print('weight in kilograms:', weight_kg, 'and in pounds:', weight_lb)
weight in kilograms: 57.5 and in pounds: 126.50000000000001
In [11]:
weight_kg = 100
print('weight in kilograms is now:', weight_kg,
      'and weight in pounds is..', weight_lb)
weight in kilograms is now: 100 and weight in pounds is.. 126.50000000000001
In [12]:
weight_kg = "hello"
In [13]:
print(weight_kg)
hello
In [14]:
print(weight_lb)
126.50000000000001
In [15]:
weight_kg = 100
In [16]:
whos
Variable    Type      Data/Info
-------------------------------
numpy       module    <module 'numpy' from '/us<...>kages/numpy/__init__.py'>
weight_kg   int       100
weight_lb   float     126.50000000000001
In [17]:
data = numpy.loadtxt(fname='data/inflammation-01.csv', delimiter=',')
In [18]:
print(data)
[[ 0.  0.  1. ...,  3.  0.  0.]
 [ 0.  1.  2. ...,  1.  0.  1.]
 [ 0.  1.  1. ...,  2.  1.  1.]
 ..., 
 [ 0.  1.  1. ...,  1.  1.  1.]
 [ 0.  0.  0. ...,  0.  2.  0.]
 [ 0.  0.  1. ...,  1.  1.  0.]]
In [19]:
print(type(data))
<class 'numpy.ndarray'>
In [20]:
data.size
Out[20]:
2400
In [21]:
data.shape
Out[21]:
(60, 40)
In [22]:
print(data.shape)
(60, 40)
In [23]:
print('first value in data:', data[0,0])
first value in data: 0.0
In [24]:
print('middle value in data:', data[30,20])
middle value in data: 13.0
In [25]:
print(data[0:4, 0:10])
[[ 0.  0.  1.  3.  1.  2.  4.  7.  8.  3.]
 [ 0.  1.  2.  1.  2.  1.  3.  2.  2.  6.]
 [ 0.  1.  1.  3.  3.  2.  6.  2.  5.  9.]
 [ 0.  0.  2.  0.  4.  2.  2.  1.  6.  7.]]
In [26]:
small = data[:3, 36:]
print('small is:')
print(small)
small is:
[[ 2.  3.  0.  0.]
 [ 1.  1.  0.  1.]
 [ 2.  2.  1.  1.]]
In [27]:
doubledata = data * 2.0
In [28]:
print('original:')
print(data[:3, 36:])
print('doubledata:')
print(doubledata[:3, 36:])
original:
[[ 2.  3.  0.  0.]
 [ 1.  1.  0.  1.]
 [ 2.  2.  1.  1.]]
doubledata:
[[ 4.  6.  0.  0.]
 [ 2.  2.  0.  2.]
 [ 4.  4.  2.  2.]]
In [29]:
tripledata = doubledata + data
In [30]:
print(tripledata[:3, 36:])
[[ 6.  9.  0.  0.]
 [ 3.  3.  0.  3.]
 [ 6.  6.  3.  3.]]
In [31]:
print(data.mean())
6.14875
In [32]:
print(doubledata.mean())
12.2975
In [33]:
data.shape
Out[33]:
(60, 40)
In [34]:
print(data.max())
20.0
In [35]:
print(data.min())
0.0
In [36]:
print(data.std())
4.61383319712
In [37]:
patient_0 = data[0, :]
print('maximum inflammation for patient 0:', patient_0.max())
maximum inflammation for patient 0: 18.0
In [40]:
print(patient_0)
print(patient_0.mean())
[  0.   0.   1.   3.   1.   2.   4.   7.   8.   3.   3.   3.  10.   5.   7.
   4.   7.   7.  12.  18.   6.  13.  11.  11.   7.   7.   4.   6.   8.   8.
   4.   4.   5.   7.   3.   4.   2.   3.   0.   0.]
5.45
In [45]:
print(data.mean(axis=0))
[  0.           0.45         1.11666667   1.75         2.43333333   3.15
   3.8          3.88333333   5.23333333   5.51666667   5.95         5.9
   8.35         7.73333333   8.36666667   9.5          9.58333333
  10.63333333  11.56666667  12.35        13.25        11.96666667
  11.03333333  10.16666667  10.           8.66666667   9.15         7.25
   7.33333333   6.58333333   6.06666667   5.95         5.11666667   3.6
   3.3          3.56666667   2.48333333   1.5          1.13333333
   0.56666667]
In [42]:
data.shape
Out[42]:
(60, 40)
In [46]:
%matplotlib inline
import matplotlib.pyplot
image = matplotlib.pyplot.imshow(data)
matplotlib.pyplot.show()
In [62]:
ave_inflammation = data.mean(axis=0)
ave_plot = matplotlib.pyplot.plot(ave_inflammation)
matplotlib.pyplot.show(ave_plot)
In [63]:
max_plot = matplotlib.pyplot.plot(data.max(axis=0))
matplotlib.pyplot.show()
In [68]:
min_plot = matplotlib.pyplot.plot(data.min(axis=0))
matplotlib.pyplot.show(min_plot)
In [75]:
import numpy
import matplotlib.pyplot

data = numpy.loadtxt(fname='data/inflammation-01.csv', delimiter=',')

fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))

axes1 = fig.add_subplot(1,3,1)
axes2 = fig.add_subplot(1,3,2)
axes3 = fig.add_subplot(1,3,3)

axes1.set_ylabel('average')
axes1.plot(data.mean(axis=0))

axes2.set_ylabel('max')
axes2.plot(data.max(axis=0))

axes3.set_ylabel('min')
axes3.plot(data.min(axis=0))

fig.tight_layout()

matplotlib.pyplot.show()
In [76]:
import numpy
import matplotlib.pyplot

data = numpy.loadtxt(fname='data/inflammation-01.csv', delimiter=',')

fig = matplotlib.pyplot.figure(figsize=(10.0,3.0))

axes1 = fig.add_subplot(1,4,1)
axes2 = fig.add_subplot(1,4,2)
axes3 = fig.add_subplot(1,4,3)
axes4 = fig.add_subplot(1,4,4)

axes1.set_ylabel('Average')
axes1.plot(data.mean(axis=0))

axes2.set_ylabel('Maximum')
axes2.plot(data.max(axis=0))

axes3.set_ylabel('Minimum')
axes3.plot(data.min(axis=0))

axes4.set_ylabel('Standard Deviation')
axes4.plot(data.std(axis=0))

fig.tight_layout()

matplotlib.pyplot.show()
In [81]:
word = 'lead'
print(word[0])
print(word[1])
print(word[2])
print(word[3])
l
e
a
d
In [82]:
print(word)
lead
In [89]:
word = "oxygen"
for char in word:
    print(char)
o
x
y
g
e
n
In [98]:
length = 0
for vowel in 'aeiouhippo':
    length = length + 1

    print('There are', length, 'vowels, and the vowel is', vowel)
There are 1 vowels, and the vowel is a
There are 2 vowels, and the vowel is e
There are 3 vowels, and the vowel is i
There are 4 vowels, and the vowel is o
There are 5 vowels, and the vowel is u
There are 6 vowels, and the vowel is h
There are 7 vowels, and the vowel is i
There are 8 vowels, and the vowel is p
There are 9 vowels, and the vowel is p
There are 10 vowels, and the vowel is o
In [97]:
my_string = 'kjasgoijaefjihadfjohoidafjhjadfh'
print(len(my_string))
32
In [109]:
my_string = 'hello'
for x in range(len(my_string)):
    print(my_string[x])
    
for x in my_string:
    print(x)
h
e
l
l
o
h
e
l
l
o
In [110]:
print(5 ** 3)
125
In [136]:
power = 4
base = 2
result = base

for x in range(1,power):
    result = result * base
    
print(result)
16
In [137]:
res = 1
for x in range(3):
    res = res*5
    
print(res)
125
In [138]:
exponent = 3
value = 3
result = 1
for i in range(1,exponent+1) :
    result = result * value
    print(result)
3
9
27
In [141]:
exp = 5
num = 10
result = 1

for x in range(exp):
    result = result*num

print(result)
100000
In [142]:
challenge = 'Newton'
reverse = ''

for ??? in ???:
    ???

print(reverse)

# notweN
100000
In [169]:
challenge[0]
Out[169]:
'N'
In [ ]:
 
In [190]:
challenge = 'Newton'
long = len(challenge)

for x in range(long-1,-1,-1):
    #print(-x)
    now = challenge[-x]
    print(now, end='')
ewtonN
In [195]:
challenge = 'Newton'
length = 0

for char in challenge:
    length = length + 1
    count = 0 - length
    print(count)
    #print(challenge[count], end='')
-1
-2
-3
-4
-5
-6
In [202]:
word = "Newton"
reverse = ''
for i in range(len(word)-1, -1, -1):
    reverse = reverse + word[i]
    
print(reverse)
notweN
In [207]:
odds = [1, 3, 5, 7]
In [208]:
len(odds)
Out[208]:
4
In [209]:
print('first andlast: ', odds[0], odds[-2])
first andlast:  1 5
In [210]:
for number in odds:
    print(number)
1
3
5
7
In [211]:
somelist = ["bla", 11234, 1.124124]
In [221]:
b = "ASDFG"
In [222]:
b[1] = "Z"
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-222-f8422f3486af> in <module>()
----> 1 b[1] = "Z"

TypeError: 'str' object does not support item assignment
In [223]:
a = ['A', 'S', 'D', 'F']
In [224]:
a[1] = 'Z'
In [225]:
print(a)
['A', 'Z', 'D', 'F']
In [226]:
''.join(a)
Out[226]:
'AZDF'
In [228]:
print(list(b))
['A', 'S', 'D', 'F', 'G']
In [229]:
b
Out[229]:
'ASDFG'
In [230]:
x = [['pepper', 'zucchini', 'onion'],
     ['cabbage', 'lettuce', 'garlic'],
     ['apple', 'pear', 'banana']]
In [231]:
print(x)
[['pepper', 'zucchini', 'onion'], ['cabbage', 'lettuce', 'garlic'], ['apple', 'pear', 'banana']]
In [232]:
print(x[0])
['pepper', 'zucchini', 'onion']
In [233]:
print(x[0][0])
pepper
In [234]:
odds.append(9)
In [235]:
print(odds)
[1, 3, 5, 7, 9]
In [236]:
del odds[0]
In [237]:
print(odds)
[3, 5, 7, 9]
In [238]:
odds.reverse()
In [239]:
print(odds)
[9, 7, 5, 3]
In [240]:
odds.extend(['a', 'c', 'b'])
In [241]:
print(odds)
[9, 7, 5, 3, 'a', 'c', 'b']
In [242]:
odds =[1,3,5,7]
In [243]:
primes = odds
In [244]:
primes += [2]
In [245]:
print('this is primes: ', primes)
print('this is odds: ', odds)
this is primes:  [1, 3, 5, 7, 2]
this is odds:  [1, 3, 5, 7, 2]
In [246]:
primes = list(odds)
In [247]:
primes[0] = 'bla'
In [248]:
print('this is primes: ', primes)
print('this is odds: ', odds)
this is primes:  ['bla', 3, 5, 7, 2]
this is odds:  [1, 3, 5, 7, 2]
In [250]:
hello = 'hello'
hello_list = ['h', 'e', 'l', 'l', 'o']
my_list = []
In [256]:
my_list = ['e']
for c in hello:
    my_list
print(my_list)
h  -> nope
e  -> yep
l  -> nope
l  -> nope
o  -> nope
['e']
In [258]:
string_to_break = 'hello'
string_list = []
for letter in string_to_break:
    string_list.append(letter)
print(string_list)
['h', 'e', 'l', 'l', 'o']
In [259]:
string_list.sort()
In [261]:
string_list.pop()
Out[261]:
'o'
In [262]:
string_list.pop()
Out[262]:
'l'
In [263]:
string_list.pop()
Out[263]:
'l'
In [264]:
string_list.pop()
Out[264]:
'h'
In [265]:
string_list.pop()
Out[265]:
'e'
In [266]:
string_list.pop()
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-266-e5ccaa9b37c5> in <module>()
----> 1 string_list.pop()

IndexError: pop from empty list
In [276]:
this_tuple = 1, 2, 3
In [277]:
a, b, c = this_tuple
In [278]:
print(a)
1
In [289]:
left = 'L'
right = 'R'

temp = left
left = 'BLA'
# left = right
right = temp
In [290]:
print('left =', left)
print('right =', right)
print('temp = ', temp)
left = BLA
right = L
temp =  L
In [285]:
left = 'L'
right = 'R'

left, right = (right, left)
In [286]:
print('left =', left)
print('right =', right)
left = R
right = L
In [291]:
import glob
In [296]:
print(glob.glob('data/inflammation*.csv'))
['data/inflammation-02.csv', 'data/inflammation-01.csv', 'data/inflammation-09.csv', 'data/inflammation-05.csv', 'data/inflammation-08.csv', 'data/inflammation-12.csv', 'data/inflammation-04.csv', 'data/inflammation-07.csv', 'data/inflammation-10.csv', 'data/inflammation-11.csv', 'data/inflammation-03.csv', 'data/inflammation-06.csv']
In [320]:
%matplotlib inline

import numpy
import matplotlib.pyplot

filenames = glob.glob('data/inflammation*.csv')
filenames.sort()
filenames = filenames[0:3]
for f in filenames:
    print(f)
    
    data = numpy.loadtxt(fname=f, delimiter=',')
    
    if data.max(axis=0)[0] == 0 and data.max(axis=0)[20] == 20:
        print("Suspicious looking maxima !!!1!")
    elif data.min(axis=0).sum() == 0:
        print("Minima add up to zero !")
    else:
        print("Seems okay. :)")
        
    
    fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))
    
    axes1 = fig.add_subplot(1 ,3, 1)
    axes2 = fig.add_subplot(1, 3, 2)
    axes3 = fig.add_subplot(1, 3, 3)
    
    axes1.set_ylabel('average')
    axes1.plot(data.mean(axis=0))
    
    axes2.set_ylabel('max')
    axes2.plot(data.max(axis=0))
    
    axes3.set_ylabel('min')
    axes3.plot(data.min(axis=0))
    
    fig.tight_layout()
    
    matplotlib.pyplot.show()
    
    
    
data/inflammation-01.csv
Suspicious looking maxima !!!1!
data/inflammation-02.csv
Suspicious looking maxima !!!1!
data/inflammation-03.csv
Minima add up to zero !
In [301]:
print(filenames)
['data/inflammation-02.csv', 'data/inflammation-01.csv', 'data/inflammation-09.csv']
In [305]:
type(data)
Out[305]:
numpy.ndarray
In [310]:
num = 37
if num > 100:
    print('greater')
else:
    print('not greater')
    
print('done')
not greater
done
In [311]:
num = 53
print ('before')
if num > 100:
    print('53 is greater than 100')
print('after')
before
after
In [314]:
num = -3
if num > 0:
    print(num, 'is +ve')
elif num == 0:
    print(num, 'is zero')
else:
    print(num, 'is -ve')
-3 is -ve
In [315]:
if (1 < 0) and (-1 < 0): # False and True
    print('both parts are True')
else:
    print('at least one part is False')
at least one part is False
In [316]:
if (1 < 0) or (-1 < 0): # False and True
    print('at least one test is True')
at least one test is True
In [317]:
if data.max(axis=0)[0] == 0 and data.max(axis=0)[20] == 20:
    print("Suspicious looking maxima !!!1!")
In [322]:
data = numpy.loadtxt(fname='data/inflammation-03.csv', delimiter=',')

if data.max(axis=0)[0] == 0 and data.max(axis=0)[20] == 20:
    print("Suspicious looking maxima !!!1!")
elif data.min(axis=0).sum() == 0:
    print("Minima add up to zero !")
else:
    print("Seems okay. :)")
Minima add up to zero !
In [326]:
4 = 5
if 4 > 5:
    print('A')
elif 4 == 5:
    print('B')
elif 4 < 5:
    print('C')
    
# Hmmmmmm. Will it print A ? Nope, 4 is not greater than 5
# Will it print B ?
  File "<ipython-input-326-c216428900eb>", line 1
    4 = 5
         ^
SyntaxError: can't assign to literal
In [327]:
this_is_a_bool = True
an_another = False
In [333]:
if '':
    print('empty string is True')
if 'word':
    print('word is True')
if []:
    print('empty list is True')
if [1,2,4]:
    print('list with stuff is True')
if 0:
    print('the number zero is True')
if 1:
    print('the number one is True')
if None:
    print('None is True')
word is True
list with stuff is True
the number one is True
In [342]:
bla = "  blblbl  "
print(bla)
print(bla.strip())
  blblbl  
blblbl
In [340]:
if not bla.strip():
    print("bla is empty")
bla is empty
In [350]:
a = 100
b = 95
print(a == b)
print(a > b * 2)
print((a > 10 * b) and (a < 2 * b))
# print( (a ? < .. ?) and (a ? > ..?))
False
False
False
In [358]:
threshold = 2
if a > b*(1 - threshold/100) and a < b*(1 + threshold/100):
    print('a is within %s percent of b' % threshold)
else:
    print('a is not within %s percent of b' % threshold)
a is not within 2 percent of b
In [360]:
x = 1
x += 1  # x = x + 1
print(x)
x *= 10
print(x)
2
20
In [362]:
nums = [-1, -3, -5, 2, 4, 8]
pos_sum = 0
neg_sum = 0
for n in nums:
    # something in here that uses in-place += operator ...
    pass
In [363]:
def fahr_to_kelvin(temp):
    return ((temp - 32) * (5/9)) + 273.15
In [364]:
print('freezing point of water:', fahr_to_kelvin(32))
print('boiling point of water:', fahr_to_kelvin(212))
freezing point of water: 273.15
boiling point of water: 373.15
In [365]:
def kelvin_to_celsius(temp_k):
    return temp_k - 273.15

print('absolute zero in celsius:', kelvin_to_celsius(0.0))
absolute zero in celsius: -273.15
In [366]:
def fahr_to_celsius(temp_f):
    temp_k = fahr_to_kelvin(temp_f)
    result = kelvin_to_celsius(temp_k)
    return result
In [367]:
print('freezing point of water in celsius:', fahr_to_celsius(32.0))
freezing point of water in celsius: 0.0
In [368]:
def analyze(filename):
    data = numpy.loadtxt(fname=filename, delimiter=',')
    
    fig = matplotlib.pyplot.figure(figsize=(10.0, 3.0))
    
    axes1 = fig.add_subplot(1, 3, 1)
    axes2 = fig.add_subplot(1, 3, 2)
    axes3 = fig.add_subplot(1, 3, 3)
    
    axes1.set_ylabel('average')
    axes1.plot(data.mean(axis=0))
    
    axes2.set_ylabel('max')
    axes2.plot(data.max(axis=0))
    
    axes3.set_ylabel('min')
    axes3.plot(data.min(axis=0))
    
    fig.tight_layout()
    
    matplotlib.pyplot.show()
In [369]:
def detect_problems(filename):
    data = numpy.loadtxt(fname=filename, delimiter=',')
    
    if data.max(axis=0)[0] == 0 and data.max(axis=0)[20] == 20:
        print("Suspicious looking maxima !!!1!")
    elif data.min(axis=0).sum() == 0:
        print("Minima add up to zero !")
    else:
        print("Seems okay. :)")
In [370]:
import numpy
import matplotlib.pyplot

filenames = glob.glob('data/inflammation*.csv')
filenames.sort()
filenames = filenames[0:3]
for f in filenames:
    print(f)
    analyze(f)
    detect_problems(f)
data/inflammation-01.csv
Suspicious looking maxima !!!1!
data/inflammation-02.csv
Suspicious looking maxima !!!1!
data/inflammation-03.csv
Minima add up to zero !
In [384]:
def center(data, desired=0.0):
    '''Return a new array containing the original data centered around the desired value'''
    return (data - data.mean()) + desired

help(data.max)
Help on built-in function max:

max(...) method of numpy.ndarray instance
    a.max(axis=None, out=None)
    
    Return the maximum along a given axis.
    
    Refer to `numpy.amax` for full documentation.
    
    See Also
    --------
    numpy.amax : equivalent function

In [372]:
z = numpy.zeros((2,2))
print(z)
[[ 0.  0.]
 [ 0.  0.]]
In [373]:
print(center(z, 3))
[[ 3.  3.]
 [ 3.  3.]]
In [385]:
data = numpy.loadtxt(fname='data/inflammation-01.csv', delimiter=',')
print(center(data))
[[-6.14875 -6.14875 -5.14875 ..., -3.14875 -6.14875 -6.14875]
 [-6.14875 -5.14875 -4.14875 ..., -5.14875 -6.14875 -5.14875]
 [-6.14875 -5.14875 -5.14875 ..., -4.14875 -5.14875 -5.14875]
 ..., 
 [-6.14875 -5.14875 -5.14875 ..., -5.14875 -5.14875 -5.14875]
 [-6.14875 -6.14875 -6.14875 ..., -6.14875 -4.14875 -6.14875]
 [-6.14875 -6.14875 -5.14875 ..., -5.14875 -5.14875 -6.14875]]
In [375]:
print('original min, mean and max are: ', data.min(), data.mean(), data.max())
centered = center(data, 0)
print('min, mean and max of centered data are:', centered.min(),
      centered.mean(), centered.max())
original min, mean and max are:  0.0 6.14875 20.0
min, mean and max of centered data are: -6.14875 2.84217094304e-16 13.85125
In [376]:
print(data.std())
4.61383319712
In [377]:
print(centered.std())
4.61383319712
In [383]:
numpy.loadtxt('data/inflammation-01.csv', delimiter=',')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-383-7924d6313a1e> in <module>()
----> 1 numpy.loadtxt('data/inflammation-01.csv', ',')

/usr/local/lib/python3.4/dist-packages/numpy/lib/npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin)
    871     try:
    872         # Make sure we're dealing with a proper dtype
--> 873         dtype = np.dtype(dtype)
    874         defconv = _getconv(dtype)
    875 

TypeError: data type "," not understood
In [386]:
def display(a=1, b=2, c=3):
    print('a:',a,'b:',b,'c:',c)
In [388]:
display()
a: 1 b: 2 c: 3
In [391]:
display(55, c=66)
a: 55 b: 2 c: 66
In [392]:
help(numpy.loadtxt)
Help on function loadtxt in module numpy.lib.npyio:

loadtxt(fname, dtype=<class 'float'>, comments='#', delimiter=None, converters=None, skiprows=0, usecols=None, unpack=False, ndmin=0)
    Load data from a text file.
    
    Each row in the text file must have the same number of values.
    
    Parameters
    ----------
    fname : file or str
        File, filename, or generator to read.  If the filename extension is
        ``.gz`` or ``.bz2``, the file is first decompressed. Note that
        generators should return byte strings for Python 3k.
    dtype : data-type, optional
        Data-type of the resulting array; default: float.  If this is a
        structured data-type, the resulting array will be 1-dimensional, and
        each row will be interpreted as an element of the array.  In this
        case, the number of columns used must match the number of fields in
        the data-type.
    comments : str or sequence, optional
        The characters or list of characters used to indicate the start of a
        comment;
        default: '#'.
    delimiter : str, optional
        The string used to separate values.  By default, this is any
        whitespace.
    converters : dict, optional
        A dictionary mapping column number to a function that will convert
        that column to a float.  E.g., if column 0 is a date string:
        ``converters = {0: datestr2num}``.  Converters can also be used to
        provide a default value for missing data (but see also `genfromtxt`):
        ``converters = {3: lambda s: float(s.strip() or 0)}``.  Default: None.
    skiprows : int, optional
        Skip the first `skiprows` lines; default: 0.
    usecols : sequence, optional
        Which columns to read, with 0 being the first.  For example,
        ``usecols = (1,4,5)`` will extract the 2nd, 5th and 6th columns.
        The default, None, results in all columns being read.
    unpack : bool, optional
        If True, the returned array is transposed, so that arguments may be
        unpacked using ``x, y, z = loadtxt(...)``.  When used with a structured
        data-type, arrays are returned for each field.  Default is False.
    ndmin : int, optional
        The returned array will have at least `ndmin` dimensions.
        Otherwise mono-dimensional axes will be squeezed.
        Legal values: 0 (default), 1 or 2.
    
        .. versionadded:: 1.6.0
    
    Returns
    -------
    out : ndarray
        Data read from the text file.
    
    See Also
    --------
    load, fromstring, fromregex
    genfromtxt : Load data with missing values handled as specified.
    scipy.io.loadmat : reads MATLAB data files
    
    Notes
    -----
    This function aims to be a fast reader for simply formatted files.  The
    `genfromtxt` function provides more sophisticated handling of, e.g.,
    lines with missing values.
    
    .. versionadded:: 1.10.0
    
    The strings produced by the Python float.hex method can be used as
    input for floats.
    
    Examples
    --------
    >>> from io import StringIO   # StringIO behaves like a file object
    >>> c = StringIO("0 1\n2 3")
    >>> np.loadtxt(c)
    array([[ 0.,  1.],
           [ 2.,  3.]])
    
    >>> d = StringIO("M 21 72\nF 35 58")
    >>> np.loadtxt(d, dtype={'names': ('gender', 'age', 'weight'),
    ...                      'formats': ('S1', 'i4', 'f4')})
    array([('M', 21, 72.0), ('F', 35, 58.0)],
          dtype=[('gender', '|S1'), ('age', '<i4'), ('weight', '<f4')])
    
    >>> c = StringIO("1,0,2\n3,0,4")
    >>> x, y = np.loadtxt(c, delimiter=',', usecols=(0, 2), unpack=True)
    >>> x
    array([ 1.,  3.])
    >>> y
    array([ 2.,  4.])

In [398]:
def fence(original, wrapper):
    result = wrapper + original + wrapper
    return result

print(fence('name', '*'))
*name*
In [397]:
print("{first_name} {last_name}".format(first_name="john", last_name="smith"))
john smith
In [ ]: