In [1]:
from __future__ import print_function

print('Hello World')


Hello World

In [3]:
from __future__ import division
3 / 2


Out[3]:
1.5

In [5]:
s = "Hello World"
s


Out[5]:
'Hello World'

In [6]:
# Let's try to change the first letter to 'x'
s[0] = 'x' # strings are immutable, i.e. cannot be chnage programatically


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-3a9c668aa5ab> in <module>()
      1 # Let's try to change the first letter to 'x'
----> 2 s[0] = 'x'

TypeError: 'str' object does not support item assignment

In [11]:
print("This is a tab \t Tab starts here") # in python 3 you need duoble quotes to have the special characters evaluated


This is a tab 	 Tab starts here

In [12]:
s = 'Hello World!'
s[0]


Out[12]:
'H'

In [15]:
s[::2]


Out[15]:
'HloWrd'

In [21]:
s[6:7]


Out[21]:
'W'

In [16]:
s[::-1]


Out[16]:
'!dlroW olleH'

In [22]:
s[:] # this means select everything


Out[22]:
'Hello World!'

In [25]:
s[1:10:3] # 1 up to 10 (not included) with incremental steps of 3


Out[25]:
'eoo'

In [ ]: