iPython 101 - using numpy, scipy, matplotlib, sqlite3 and Bokeh.

it takes a long time to load - be patient!


In [1]:
a = "hello world - BRUCE"
print(a)
import time

#print("date and time when this Notebook was run on http://localhost:8888/notebooks/ipython_101_notebook-Copy1.ipynb")
print("Date & Time : ",time.strftime("%Y-%m-%d  %H:%M:%S"))


hello world - BRUCE
Date & Time :  2016-08-21  13:48:36

In [ ]:


In [2]:
__author__ = 'Bruce.Woodley'
# version 3
#http://sqlite.org/
#https://addons.mozilla.org/en-us/firefox/addon/sqlite-manager/
#For Ankur Pandey's  "sql learnings"
def main():
    import sqlite3
    import time

    conn = sqlite3.connect('music.sqlite3')
    cur = conn.cursor()
    cur.execute('DROP TABLE IF EXISTS Tracks')
    cur.execute('CREATE TABLE Tracks (title TEXT , plays INTEGER)')
    conn.close()

    conn = sqlite3.connect('music.sqlite3')
    cur = conn.cursor()
    cur.execute('INSERT INTO Tracks (title, plays) VALUES (?, ?)', ('Thunderstruck',20) )
    cur.execute('INSERT INTO Tracks (title, plays) VALUES (?, ?)',('My Way', 15) )
    cur.execute('INSERT INTO Tracks (title, plays) VALUES (?, ?)',('Lean On (by Major Lazer & DJ Snake)', 100) )
    conn.commit()

    print("Tracks:")
    cur.execute('SELECT title, plays FROM Tracks')
    for row in cur :
       print(row)
    cur.execute('DELETE FROM Tracks WHERE plays < 100')
    conn.commit()
    cur.close()
    
    print("\n")
    print("Ankur's SQL Learnings executed on date and time: ",time.strftime("%Y-%m-%d  %H:%M:%S"))
    return

main()


Tracks:
('Thunderstruck', 20)
('My Way', 15)
('Lean On (by Major Lazer & DJ Snake)', 100)


Ankur's SQL Learnings executed on date and time:  2016-08-21  13:48:37

In [ ]:


In [ ]:


In [ ]:


In [3]:
import numpy as np 
from bokeh.plotting import  show, figure 
from bokeh.io import output_notebook

x = np.linspace(-1.0*np.pi, 2*np.pi, 400) 
#print(x)
y1 = np.sin(x) 
#y2 =np.exp(x)

output_notebook() 

p = figure() 
p.circle(x, y1, legend="sin(x)",line_color="orange") 
#p.circle(x, y2, legend="exp(x)",line_color="orange") 




show(p)


Loading BokehJS ...
Out[3]:

<Bokeh Notebook handle for In[3]>


In [ ]:


In [ ]:


In [4]:
import math
math.sin(math.pi/2)


Out[4]:
1.0

In [5]:
#from numpy import pi,linspace,sin
#from matplotlib.pyplot import plot
#x = linspace(0,3*pi,500)
#print(x)
#plot(x,sin(x**2))
#title('A simple chirp');
# OneNote Python 101 - Worked Exampes - bokeh multi line, multi axis 


import numpy as np 
from bokeh.plotting import  show, figure 
from bokeh.io import output_notebook

x = np.linspace(0, 2*np.pi, 100) 
#print(x)
y = np.sin(1/x) 

output_notebook() 

p = figure() 
 
p.line(x, y, legend="sin(1/x)") 



show(p)


Loading BokehJS ...
Out[5]:

<Bokeh Notebook handle for In[5]>