In [1]:
cities = ['NY', 'LA', 'SF']
In [2]:
for city in cities:
    print(city)
NY
LA
SF
In [3]:
for city in cities:
    phrase = 'I love ' + city
    print(phrase)
I love NY
I love LA
I love SF
In [6]:
for n in range(1,10):
    print('The inverse of', n, 'is', 1.0/n)
The inverse of 1 is 1.0
The inverse of 2 is 0.5
The inverse of 3 is 0.3333333333333333
The inverse of 4 is 0.25
The inverse of 5 is 0.2
The inverse of 6 is 0.16666666666666666
The inverse of 7 is 0.14285714285714285
The inverse of 8 is 0.125
The inverse of 9 is 0.1111111111111111
In [7]:
for letter in 'Hello':
    print(letter)
H
e
l
l
o
In [13]:
cities[0:2]
Out[13]:
['NY', 'LA']
In [16]:
if city == 'NY':
    print('Party')
else:
    print('Work')
Party
In [15]:
city = 'NY'
In [17]:
1 == 2
Out[17]:
False
In [18]:
2 == 2
Out[18]:
True
In [19]:
3 > 4
Out[19]:
False
In [20]:
4 < 5
Out[20]:
True
In [21]:
1 <= 2
Out[21]:
True
In [22]:
1 != 2
Out[22]:
True
In [23]:
1 >= 0
Out[23]:
True
In [26]:
'Hello' == 'hello'
Out[26]:
False
In [28]:
'Hello' == 'Hello'
Out[28]:
True
In [ ]: