In [1]:
64**2


Out[1]:
4096

In [2]:
64**0.5


Out[2]:
8.0

In [3]:
0.1+0.2-0.3


Out[3]:
5.551115123125783e-17

In [8]:
0.100000000+0.20000000-0.30000000000


Out[8]:
5.551115123125783e-17

In [9]:
print "Hello world"


Hello world

In [10]:
print 'jello\nworld'


jello
world

In [11]:
print("jello")


jello

In [12]:
print(' "this is a quote" ')


 "this is a quote" 

In [13]:
'hello world'
'hello jello'


Out[13]:
'hello jello'

In [14]:
len('hello')


Out[14]:
5

In [15]:
s = 'jello world'

In [16]:
s


Out[16]:
'jello world'

In [17]:
print(s)


jello world

In [18]:
s[0]


Out[18]:
'j'

In [20]:
s[0..2]


  File "<ipython-input-20-29da2011c22a>", line 1
    s[0..2]
         ^
SyntaxError: invalid syntax

In [21]:
s[1:]


Out[21]:
'ello world'

In [22]:
s[:4]


Out[22]:
'jell'

In [23]:
s[:-4]


Out[23]:
'jello w'

In [24]:
s[::3]


Out[24]:
'jlwl'

In [25]:
s[-1:-3]


Out[25]:
''

In [26]:
s[:4:2]


Out[26]:
'jl'

In [27]:
s[::-1]


Out[27]:
'dlrow ollej'

In [29]:
s[1:-1]


Out[29]:
'ello worl'

In [30]:
s[::-1][::-1]


Out[30]:
'jello world'

In [31]:
s[0]


Out[31]:
'j'

In [32]:
s[0] = "H"


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-32-115ae82a5b85> in <module>()
----> 1 s[0] = "H"

TypeError: 'str' object does not support item assignment

In [33]:
s = "Sjup"

In [34]:
s


Out[34]:
'Sjup'

In [35]:
s + "Hello world"


Out[35]:
'SjupHello world'

In [37]:
s.upper()


Out[37]:
'SJUP'

In [38]:
s.expand()


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-38-10554f86d72c> in <module>()
----> 1 s.expand()

AttributeError: 'str' object has no attribute 'expand'

In [39]:
s.split()


Out[39]:
['Sjup']

In [40]:
s = "Hello world"

In [41]:
s.split("e")


Out[41]:
['H', 'llo world']

In [43]:
"string with {}".format("value")


Out[43]:
'string with value'

In [44]:
s = 'String'

In [45]:
print 'Place my variable here: %s' %(s)


Place my variable here: String

In [46]:
world = 'World'

In [50]:
print 'Hello, %s. I am %s' % (s, "louis")


Hello, String. I am louis

In [51]:
print 'Floating point: %1.2f' % (12.3123)


Floating point: 12.31

In [53]:
print 'Hello, {x}. I am {y}. {x}'.format(x='world', y='louis')


Hello, world. I am louis. world

In [54]:
from __future__ import print_function

In [55]:
print('hello {x}'.format(x="insert"))


hello insert

In [ ]: