In [1]:
isMLGeek


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-9acb6694049e> in <module>()
----> 1 isMLGeek

NameError: name 'isMLGeek' is not defined

In [2]:
isMLGeek = True
if isMLGeek:
    print 'I recommend you to read "DIY Machine Learning Systems for Kaggle Competitions with Python Programming"!'


I recommend you to read "DIY Machine Learning Systems for Kaggle Competitions with Python Programming"!

In [3]:
10 + 20


Out[3]:
30

In [4]:
30 - 60.6


Out[4]:
-30.6

In [5]:
4 * 8.9


Out[5]:
35.6

In [6]:
5 / 4


Out[6]:
1

In [7]:
5.0 / 4


Out[7]:
1.25

In [8]:
5 % 4


Out[8]:
1

In [9]:
2.0 ** 3


Out[9]:
8.0

In [10]:
10 < 20


Out[10]:
True

In [11]:
10 > 20


Out[11]:
False

In [12]:
30 <= 30.0


Out[12]:
True

In [13]:
30.0 >= 30.0


Out[13]:
True

In [14]:
30 == 40


Out[14]:
False

In [15]:
30 != 40


Out[15]:
True

In [16]:
t = (1, 'abc', 0.4)
t[0] = 2


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-16-e331d33fe590> in <module>()
      1 t = (1, 'abc', 0.4)
----> 2 t[0] = 2

TypeError: 'tuple' object does not support item assignment

In [17]:
l = [1, 'abc', 0.4]
l[0] = 2
l[0] += 1
l[0]


Out[17]:
3

In [18]:
l[0] -= 2
l[0]


Out[18]:
1

In [19]:
True and True


Out[19]:
True

In [20]:
True and False


Out[20]:
False

In [21]:
True or False


Out[21]:
True

In [22]:
False or False


Out[22]:
False

In [23]:
not True


Out[23]:
False

In [24]:
l = [1, 'abc', 0.4]
t = (1, 'abc', 0.4)
d = {1:'1', 'abc':0.1, 0.4:80}

In [25]:
0.4 in l


Out[25]:
True

In [26]:
1 in t


Out[26]:
True

In [27]:
'abc' in d


Out[27]:
True

In [28]:
0.1 in d


Out[28]:
False

In [29]:
b = True

In [30]:
if b:
    print "It's True!"
else:
    print "It's False!"


It's True!

In [31]:
b = False
c = True

if b:
    print "b is True!"
elif c:
    print "c is True!"
else:
    print "Both are False!"


c is True!

In [32]:
b = False
c = False
if b:
    print "b is True!"
elif c:
    print "c is True!"
else:
    print "Both are False!"


Both are False!

In [33]:
d = {1:'1', 'abc':0.1, 0.4:80}
for k in d:
    print k, ":", d[k]


1 : 1
abc : 0.1
0.4 : 80

In [34]:
def foo(x):
    return x ** 2

foo(8.0)


Out[34]:
64.0

In [35]:
import math
math.exp(2)


Out[35]:
7.38905609893065

In [36]:
from math import exp
exp(2)


Out[36]:
7.38905609893065

In [37]:
from math import exp as ep
ep(2)


Out[37]:
7.38905609893065

In [ ]: