In [2]:
%matplotlib inline

In [4]:
x=[]
x.append(1)
x


Out[4]:
[1]
$$ x $$

In [5]:
"""
Origin: A simple example.
Filename: example_scatter.py
Author: Tyler Abbot
Last modified: 15 September, 2015

qsdlmkfjdlmqksdfj
"""
import matplotlib.pyplot as plt
import random

x, y = [], []
for i in range(0,50):
   #This is a comment
   x.append(random.random())
   y.append(random.random())

plt.scatter(x, y)
plt.xlabel('x')
plt.ylabel('y')
plt.title('A Bivariate Uniform Random Variable')
plt.show()


/home/pi/env/lib/python3.4/site-packages/matplotlib/collections.py:590: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if self._edgecolors == str('face'):

In [16]:
x = [[1,1], [2,2]]
x[1]


Out[16]:
[2, 2]

In [19]:
words = ['hello', 'there', 'everyone', 1]
for word in words: 
    print(word)
    print(word +1)


hello
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-19-6d45aa056b22> in <module>()
      2 for word in words:
      3     print(word)
----> 4     print(word +1)

TypeError: Can't convert 'int' object to str implicitly

In [ ]:
x = 1
while True:
    print("To infinity and beyond! We're getting close,"\
           + " on %d now!" % (x))
    x += 1
    break

In [20]:
#Create a string
x = "You better fill this in at some point..."
print(x)


You better fill this in at some point...

In [27]:
y = list(range(0,10))
print(y)
print(x[:2])
#Slice a string
print(x[:-3])


[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
Yo
You better fill this in at some point

In [ ]:
#Create a string
x = "You better fill this in at some point..."
print(x)

#Slice a string
print(x[:-3])

#Change the case
print(x.lower())
print(x.upper())

#Find the index of a substring
print(x.find('fill'))
print(x[11:])

In [ ]:
#Define a tuple
tup = 1, 2, 3
tup1 = ("a", "b", "c")
print(tup)
print(tup1)

#Retrieving tuple data
print(tup[0])

#This won't work, since tuples are immutable
tup[0] = 1

In [ ]:
#Define a dictionary
packages = {'NumPy': 'arrays',
            'SciPy': 'numerical methods',
            'Pandas': 'statistics'}

#Get info
print(packages.items())
print(packages.get('matplotlib'))
print(packages['NumPy'])

#Loop through the dictionary
for package, use in packages.items():
    print("%s is most useful for %s." %(package, use))