diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..5df8d59b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+slides_sources/build
diff --git a/Examples/README.rst b/Examples/README.rst
new file mode 100644
index 00000000..f5a5ccb3
--- /dev/null
+++ b/Examples/README.rst
@@ -0,0 +1,4 @@
+Example code, etc.
+
+Random stuff here.
+
diff --git a/Examples/Session01/schedule.py b/Examples/Session01/schedule.py
new file mode 100644
index 00000000..fb9602de
--- /dev/null
+++ b/Examples/Session01/schedule.py
@@ -0,0 +1,40 @@
+"""
+Schedule students for lightning talks, fall 2014
+"""
+import random
+
+students = open('students.txt').readlines()
+
+# remove the header line
+del students[0]
+
+# clean it up a bit:
+
+# remove the languages, colon, etc.
+students = [line.split(":")[0] for line in students]
+
+# reverse the first, last names
+
+# separate them:
+students = [line.split(",") for line in students]
+
+# put them back together
+students = [first + last for last, first in students]
+
+random.shuffle(students)
+
+weeks = range(2,11)
+
+weeks4 = weeks*4
+
+schedule = zip(weeks4, students)
+
+schedule.sort()
+
+outfile = open('schedule.txt', 'w')
+
+for week, student in schedule:
+ line = 'week %s: %s\n' % (week, student)
+ print line,
+ outfile.write(line)
+outfile.close()
diff --git a/Examples/Session01/schedule.txt b/Examples/Session01/schedule.txt
new file mode 100644
index 00000000..59a173f1
--- /dev/null
+++ b/Examples/Session01/schedule.txt
@@ -0,0 +1,35 @@
+week 2: Chantal Huynh
+week 2: Eric Buer
+week 2: Ian M Davis
+week 2: Schuyler Alan Schwafel
+week 3: James Brent Nunn
+week 3: Lauren Fries
+week 3: Lesley D Reece
+week 3: Michel Claessens
+week 4: Benjamin C Mier
+week 4: Robert W Perkins
+week 4: Vinay Gupta
+week 4: Wayne R Fukuhara
+week 5: Darcy Balcarce
+week 5: David Fugelso
+week 5: Henry B Fischer
+week 5: Kyle R Hart
+week 6: Aleksey Kramer
+week 6: Alexander R Galvin
+week 6: Gideon I Sylvan
+week 6: Hui Zhang
+week 7: Andrew P Klock
+week 7: Danielle G Marcos
+week 7: Ousmane Conde
+week 7: Salim Hassan Hamed
+week 8: Alireza Hashemloo
+week 8: Arielle R Simmons
+week 8: Eric W Westman
+week 8: Ryan J Albright
+week 9: Alexandra N Kazakova
+week 9: Erik Ivan Lottsfeldt
+week 9: Louis John Ascoli
+week 9: Ralph P Brand
+week 10: Bryan L Davis
+week 10: Carolyn J Evans
+week 10: Changqing Zhu
diff --git a/Examples/Session01/students.txt b/Examples/Session01/students.txt
new file mode 100644
index 00000000..59d4840a
--- /dev/null
+++ b/Examples/Session01/students.txt
@@ -0,0 +1,36 @@
+name: languages
+Albright, Ryan J : VBA,
+Ascoli, Louis John : Basic, assm, shell
+Balcarce, Darcy : matlab, autocad, python
+Brand, Ralph P : C, C++, SQL,
+Buer, Eric : matlab, VBA, SQL,
+Claessens, Michel : VBA, basic SQL, pascal, matlab
+Conde, Ousmane :
+Davis, Bryan L :
+Davis, Ian M : C++
+Evans, Carolyn J : SQL,
+Fischer, Henry B : C, VB, SQL, SAS,
+Fries, Lauren : python
+Fugelso, David : C, C++, C#, Java
+Fukuhara, Wayne R : VB,
+Galvin, Alexander R : shell, C++, python
+Gupta, Vinay : C, C++, shell
+Hamed, Salim Hassan : Java, R, SAS, VBA
+Hart, Kyle R : QBasic, HTML,
+Hashemloo, Alireza :Javascript, PHP, C++
+Huynh, Chantal : Basic, SQL, Stata
+Kazakova, Alexandra N : R, python,
+Klock, Andrew P : C++, R, perl
+Kramer, Aleksey :Java, R, shell
+Lottsfeldt, Erik Ivan : basic, fortran,
+Marcos, Danielle G : python
+Mier, Benjamin C : C++, C#,
+Nunn, James Brent : shell, SQL, perl, pl1
+Perkins, Robert W : fortran, pascal, stata, javascript, sql
+Reece, Lesley D : html, SQL, PLSQL, perl, shell
+Schwafel, Schuyler Alan : bash, python, perl, php
+Simmons, Arielle R : Scheme, Java, VBA, python
+Sylvan, Gideon I :
+Westman, Eric W : C#, PHP, SQL, javascript
+Zhang, Hui : FoxBase
+Zhu, Changqing : C,
diff --git a/Examples/Session01/test.py b/Examples/Session01/test.py
new file mode 100644
index 00000000..2304d6c1
--- /dev/null
+++ b/Examples/Session01/test.py
@@ -0,0 +1,8 @@
+x = 5
+y = 56
+
+print x, y
+
+def f():
+ x = 5
+
diff --git a/Examples/Session02/codingbat.rst b/Examples/Session02/codingbat.rst
new file mode 100644
index 00000000..9f3c5d74
--- /dev/null
+++ b/Examples/Session02/codingbat.rst
@@ -0,0 +1,50 @@
+Coding Bat examples
+######################
+
+Warmup-1 > monkey_trouble
+============================
+
+We have two monkeys, a and b, and the parameters a_smile and b_smile indicate if each is smiling. We are in trouble if they are both smiling or if neither of them is smiling. Return True if we are in trouble::
+
+ monkey_trouble(True, True) → True
+ monkey_trouble(False, False) → True
+ monkey_trouble(True, False) → False
+
+
+Warmup-1 > sleep_in
+=======================
+
+The parameter weekday is True if it is a weekday, and the parameter vacation is True if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return True if we sleep in.
+
+sleep_in(False, False) → True
+sleep_in(True, False) → False
+sleep_in(False, True) → True
+
+
+Warmup-1 > diff21
+=======================
+
+Given an int n, return the absolute difference between n and 21, except return double the absolute difference if n is over 21.
+
+diff21(19) → 2
+diff21(10) → 11
+diff21(21) → 0
+
+Warmup-1 > makes10
+======================
+
+Given 2 ints, a and b, return True if one if them is 10 or if their sum is 10.
+
+makes10(9, 10) → True
+makes10(9, 9) → False
+makes10(1, 9) → True
+
+Logic-1 > cigar_party
+======================
+
+When squirrels get together for a party, they like to have cigars. A squirrel party is successful when the number of cigars is between 40 and 60, inclusive. Unless it is the weekend, in which case there is no upper bound on the number of cigars. Return True if the party with the given values is successful, or False otherwise.
+
+cigar_party(30, False) → False
+cigar_party(50, False) → True
+cigar_party(70, True) → True
+
diff --git a/Examples/Session04/format_test.py b/Examples/Session04/format_test.py
new file mode 100644
index 00000000..f3380d46
--- /dev/null
+++ b/Examples/Session04/format_test.py
@@ -0,0 +1,3 @@
+def print_msg(t):
+ print ("the first %i numbers are: " + ", ".join(["%i"] * len(t)) ) % ((len(t),) + t)
+
diff --git a/Examples/Session04/junk2.txt b/Examples/Session04/junk2.txt
new file mode 100644
index 00000000..e69de29b
diff --git a/Examples/Session04/junkfile.txt b/Examples/Session04/junkfile.txt
new file mode 100644
index 00000000..c28c057c
--- /dev/null
+++ b/Examples/Session04/junkfile.txt
@@ -0,0 +1 @@
+some textsome more text
\ No newline at end of file
diff --git a/Examples/Session04/simple_text_file.txt b/Examples/Session04/simple_text_file.txt
new file mode 100644
index 00000000..acec0797
--- /dev/null
+++ b/Examples/Session04/simple_text_file.txt
@@ -0,0 +1,2 @@
+This is a text file with very little in it
+but it at least has more than one line
diff --git a/Examples/Session04/test_file2.txt b/Examples/Session04/test_file2.txt
new file mode 100644
index 00000000..1708fac3
--- /dev/null
+++ b/Examples/Session04/test_file2.txt
@@ -0,0 +1,2 @@
+antoher simple text file
+still with jsut a couple lines in it
diff --git a/Examples/Session05/arg_test.py b/Examples/Session05/arg_test.py
new file mode 100644
index 00000000..c84b5bdf
--- /dev/null
+++ b/Examples/Session05/arg_test.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+
+import sys
+
+print sys.argv
+
diff --git a/Examples/Session06/class.py b/Examples/Session06/class.py
new file mode 100644
index 00000000..1c131142
--- /dev/null
+++ b/Examples/Session06/class.py
@@ -0,0 +1,8 @@
+class C(object):
+ x = 5
+ def __init__(self, y):
+ self.y = y
+ def meth(self, z):
+ return self.x + self.y + z
+
+
\ No newline at end of file
diff --git a/Examples/Session06/class_demo.py b/Examples/Session06/class_demo.py
new file mode 100644
index 00000000..33841a88
--- /dev/null
+++ b/Examples/Session06/class_demo.py
@@ -0,0 +1,10 @@
+
+class C(object):
+ x = 5
+
+ def __init__(self, y):
+ self.y = y
+
+ def meth(self, z):
+ C.x = z
+ return self.x + self.y + z
diff --git a/Examples/Session06/html_render/.DS_Store b/Examples/Session06/html_render/.DS_Store
new file mode 100644
index 00000000..5008ddfc
Binary files /dev/null and b/Examples/Session06/html_render/.DS_Store differ
diff --git a/Examples/Session06/html_render/html_render.py b/Examples/Session06/html_render/html_render.py
new file mode 100755
index 00000000..20faa272
--- /dev/null
+++ b/Examples/Session06/html_render/html_render.py
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+"""
+Python class example.
+
+"""
+
+
+# The start of it all:
+# Fill it all in here.
+class Element(object):
+ tag = 'html'
+ indent = ' '
+
+ def __init__(self, content=None):
+ if content is not None:
+ self.content = [str(content)]
+ else:
+ self.content = []
+
+ def append(self, new_content):
+ """ add some new content to the element"""
+ self.content.append(new_content)
+
+ def render(self, file_out, ind=""):
+ """render the content to the given file like object"""
+
+ file_out.write( ind+"<"+self.tag+">\n"+ind+self.indent )
+ file_out.write( ("\n"+ind+self.indent).join(self.content) )
+ file_out.write( "\n"+ind+""+self.tag+">" )
+
+
diff --git a/Examples/Session06/html_render/html_render.pyc b/Examples/Session06/html_render/html_render.pyc
new file mode 100644
index 00000000..727b7b1e
Binary files /dev/null and b/Examples/Session06/html_render/html_render.pyc differ
diff --git a/Examples/Session06/html_render/run_html_render.py b/Examples/Session06/html_render/run_html_render.py
new file mode 100644
index 00000000..5f6e09fa
--- /dev/null
+++ b/Examples/Session06/html_render/run_html_render.py
@@ -0,0 +1,225 @@
+#!/usr/bin/env python
+
+"""
+a simple script can run and test your html rendering classes.
+
+Uncomment the steps as you add to your rendering.
+
+"""
+from io import open, StringIO
+
+
+# importing the html_rendering code with a short name for easy typing.
+import html_render as hr
+reload(hr)
+
+
+## writing the file out:
+def render(page, filename):
+ """
+ render the tree of elements
+
+ This uses cSstringIO to render to memory, then dump to console and
+ write to file -- very handy!
+ """
+
+ f = StringIO()
+ page.render(f, u" ")
+
+ f.seek(0)
+
+ print f.read()
+
+ f.seek(0)
+ open(filename, 'w', encoding="utf-8").write( f.read() )
+
+
+## Step 1
+##########
+
+page = hr.Element()
+
+page.append(u"Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text")
+
+page.append(u"And here is another piece of text -- you should be able to add any number")
+
+render(page, u"test_html_output1.html")
+
+# ## Step 2
+# ##########
+
+# page = hr.Html()
+
+# body = hr.Body()
+
+# body.append(hr.P(u"Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text"))
+
+# body.append(hr.P(u"And here is another piece of text -- you should be able to add any number"))
+
+# page.append(body)
+
+# render(page, u"test_html_output2.html")
+
+# # Step 3
+# ##########
+
+# page = hr.Html()
+
+# head = hr.Head()
+# head.append(hr.Title(u"PythonClass = Revision 1087:"))
+
+# page.append(head)
+
+# body = hr.Body()
+
+# body.append(hr.P(u"Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text"))
+# body.append(hr.P(u"And here is another piece of text -- you should be able to add any number"))
+
+# page.append(body)
+
+# render(page, u"test_html_output3.html")
+
+# # Step 4
+# ##########
+
+# page = hr.Html()
+
+# head = hr.Head()
+# head.append(hr.Title(u"PythonClass = Revision 1087:"))
+
+# page.append(head)
+
+# body = hr.Body()
+
+# body.append(hr.P(u"Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
+# style=u"text-align: center; font-style: oblique;"))
+
+# page.append(body)
+
+# render(page, u"test_html_output4.html")
+
+# # Step 5
+# #########
+
+# page = hr.Html()
+
+# head = hr.Head()
+# head.append(hr.Title(u"PythonClass = Revision 1087:"))
+
+# page.append(head)
+
+# body = hr.Body()
+
+# body.append(hr.P(u"Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
+# style=u"text-align: center; font-style: oblique;"))
+
+# body.append(hr.Hr())
+
+# page.append(body)
+
+# render(page, u"test_html_output5.html")
+
+# # Step 6
+# #########
+
+# page = hr.Html()
+
+# head = hr.Head()
+# head.append(hr.Title(u"PythonClass = Revision 1087:"))
+
+# page.append(head)
+
+# body = hr.Body()
+
+# body.append(hr.P(u"Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
+# style=u"text-align: center; font-style: oblique;"))
+
+# body.append(hr.Hr())
+
+# body.append(u"And this is a ")
+# body.append( hr.A(u"http://google.com", "link") )
+# body.append(u"to google")
+
+# page.append(body)
+
+# render(page, u"test_html_output6.html")
+
+# # Step 7
+# #########
+
+# page = hr.Html()
+
+# head = hr.Head()
+# head.append(hr.Title(u"PythonClass = Revision 1087:"))
+
+# page.append(head)
+
+# body = hr.Body()
+
+# body.append( hr.H(2, u"PythonClass - Class 6 example") )
+
+# body.append(hr.P(u"Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
+# style=u"text-align: center; font-style: oblique;"))
+
+# body.append(hr.Hr())
+
+# list = hr.Ul(id=u"TheList", style=u"line-height:200%")
+
+# list.append( hr.Li(u"The first item in a list") )
+# list.append( hr.Li(u"This is the second item", style="color: red") )
+
+# item = hr.Li()
+# item.append(u"And this is a ")
+# item.append( hr.A(u"http://google.com", u"link") )
+# item.append(u"to google")
+
+# list.append(item)
+
+# body.append(list)
+
+# page.append(body)
+
+# render(page, u"test_html_output7.html")
+
+# # Step 8
+# ########
+
+# page = hr.Html()
+
+
+# head = hr.Head()
+# head.append( hr.Meta(charset=u"UTF-8") )
+# head.append(hr.Title(u"PythonClass = Revision 1087:"))
+
+# page.append(head)
+
+# body = hr.Body()
+
+# body.append( hr.H(2, u"PythonClass - Class 6 example") )
+
+# body.append(hr.P(u"Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text",
+# style=u"text-align: center; font-style: oblique;"))
+
+# body.append(hr.Hr())
+
+# list = hr.Ul(id=u"TheList", style=u"line-height:200%")
+
+# list.append( hr.Li(u"The first item in a list") )
+# list.append( hr.Li(u"This is the second item", style="color: red") )
+
+# item = hr.Li()
+# item.append(u"And this is a ")
+# item.append( hr.A(u"http://google.com", "link") )
+# item.append(u"to google")
+
+# list.append(item)
+
+# body.append(list)
+
+# page.append(body)
+
+# render(page, u"test_html_output8.html")
+
+
+
+
diff --git a/Examples/Session06/html_render/sample_html.py b/Examples/Session06/html_render/sample_html.py
new file mode 100644
index 00000000..f2687e95
--- /dev/null
+++ b/Examples/Session06/html_render/sample_html.py
@@ -0,0 +1,27 @@
+
+
+
+
+ PythonClass = Revision 1087:
+
+
+ PythonClass - Class 6 example
+
+ Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text
+
+
+
+ -
+ The first item in a list
+
+ -
+ This is the second item
+
+ -
+ And this is a
+ link
+ to google
+
+
+
+
\ No newline at end of file
diff --git a/Examples/Session06/html_render/test_html_output1.html b/Examples/Session06/html_render/test_html_output1.html
new file mode 100644
index 00000000..c1ed9a30
--- /dev/null
+++ b/Examples/Session06/html_render/test_html_output1.html
@@ -0,0 +1,4 @@
+
+ Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text
+ And here is another piece of text -- you should be able to add any number
+
\ No newline at end of file
diff --git a/Examples/Session06/html_render/test_html_output2.html b/Examples/Session06/html_render/test_html_output2.html
new file mode 100644
index 00000000..25d5cdc9
--- /dev/null
+++ b/Examples/Session06/html_render/test_html_output2.html
@@ -0,0 +1,11 @@
+
+
+
+
+ Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text
+
+
+ And here is another piece of text -- you should be able to add any number
+
+
+
\ No newline at end of file
diff --git a/Examples/Session06/html_render/test_html_output3.html b/Examples/Session06/html_render/test_html_output3.html
new file mode 100644
index 00000000..b5b308cc
--- /dev/null
+++ b/Examples/Session06/html_render/test_html_output3.html
@@ -0,0 +1,14 @@
+
+
+
+ PythonClass = Revision 1087:
+
+
+
+ Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text
+
+
+ And here is another piece of text -- you should be able to add any number
+
+
+
\ No newline at end of file
diff --git a/Examples/Session06/html_render/test_html_output4.html b/Examples/Session06/html_render/test_html_output4.html
new file mode 100644
index 00000000..671fee75
--- /dev/null
+++ b/Examples/Session06/html_render/test_html_output4.html
@@ -0,0 +1,11 @@
+
+
+
+ PythonClass = Revision 1087:
+
+
+
+ Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text
+
+
+
\ No newline at end of file
diff --git a/Examples/Session06/html_render/test_html_output5.html b/Examples/Session06/html_render/test_html_output5.html
new file mode 100644
index 00000000..92d4748d
--- /dev/null
+++ b/Examples/Session06/html_render/test_html_output5.html
@@ -0,0 +1,12 @@
+
+
+
+ PythonClass = Revision 1087:
+
+
+
+ Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text
+
+
+
+
\ No newline at end of file
diff --git a/Examples/Session06/html_render/test_html_output6.html b/Examples/Session06/html_render/test_html_output6.html
new file mode 100644
index 00000000..342e88cf
--- /dev/null
+++ b/Examples/Session06/html_render/test_html_output6.html
@@ -0,0 +1,15 @@
+
+
+
+ PythonClass = Revision 1087:
+
+
+
+ Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text
+
+
+ And this is a
+ link
+ to google
+
+
\ No newline at end of file
diff --git a/Examples/Session06/html_render/test_html_output7.html b/Examples/Session06/html_render/test_html_output7.html
new file mode 100644
index 00000000..cac89eaf
--- /dev/null
+++ b/Examples/Session06/html_render/test_html_output7.html
@@ -0,0 +1,26 @@
+
+
+
+ PythonClass = Revision 1087:
+
+
+ PythonClass - Class 6 example
+
+ Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text
+
+
+
+ -
+ The first item in a list
+
+ -
+ This is the second item
+
+ -
+ And this is a
+ link
+ to google
+
+
+
+
\ No newline at end of file
diff --git a/Examples/Session06/html_render/test_html_output8.html b/Examples/Session06/html_render/test_html_output8.html
new file mode 100644
index 00000000..f2687e95
--- /dev/null
+++ b/Examples/Session06/html_render/test_html_output8.html
@@ -0,0 +1,27 @@
+
+
+
+
+ PythonClass = Revision 1087:
+
+
+ PythonClass - Class 6 example
+
+ Here is a paragraph of text -- there could be more of them, but this is enough to show that we can do some text
+
+
+
+ -
+ The first item in a list
+
+ -
+ This is the second item
+
+ -
+ And this is a
+ link
+ to google
+
+
+
+
\ No newline at end of file
diff --git a/Examples/Session06/simple_classes.py b/Examples/Session06/simple_classes.py
new file mode 100644
index 00000000..b170209d
--- /dev/null
+++ b/Examples/Session06/simple_classes.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+"""
+simple_classes.py
+
+demonstrating the basics of a class
+"""
+
+import math
+
+
+## create a point class
+class Point(object):
+ def __init__(self, x, y):
+ self.x = x
+ self.y = y
+
+## create an instance of that class
+p = Point(3,4)
+
+## access the attributes
+print "p.x is:", p.x
+print "p.y is:", p.y
+
+
+class Point2(object):
+ size = 4
+ color= "red"
+ def __init__(self, x, y):
+ self.x = x
+ self.y = y
+
+p2 = Point2(4,5)
+print p2.size
+print p2.color
+
+
+class Point3(object):
+ size = 4
+ color= "red"
+ def __init__(self, x, y):
+ self.x = x
+ self.y = y
+ def get_color(self):
+ return self.color
+
+
+p3 = Point3(4,5)
+print p3.size
+print p3.get_color()
+
+
+class Circle(object):
+ color = "red"
+ styles = ['dashed']
+ def __init__(self, diameter):
+ self.diameter = diameter
+
+ def grow(self, factor=2):
+ """
+ grows the circle's diameter
+
+ :param factor=2: factor by which to grow the circle
+ """
+ self.diameter = self.diameter * factor
+
+ def add_style(self, style):
+ self.styles.append(style)
+
+ def get_area(self):
+ return math.pi * self.diameter / 2.0
+
+
+class NewCircle(Circle):
+ color = "blue"
+
+ def grow(self, factor=2):
+ """grows the area by factor..."""
+ self.diameter = self.diameter * math.sqrt(2)
+
+nc = NewCircle
+print nc.color
+
+
+class CircleR(Circle):
+ def __init__(self, radius):
+ diameter = radius*2
+ Circle.__init__(self, diameter)
+
+
+class CircleR2(Circle):
+ def __init__(self, radius):
+ self.radius = radius
+
+ def get_area(self):
+ return Circle.get_area(self, self.radius*2)
diff --git a/Examples/Session07/circle.py b/Examples/Session07/circle.py
new file mode 100644
index 00000000..a6545632
--- /dev/null
+++ b/Examples/Session07/circle.py
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+"""circle class --
+
+fill this in so it will pass all the tests.
+"""
+import math
+
+
+class Circle(object):
+ pass
diff --git a/Examples/Session07/test_circle1.py b/Examples/Session07/test_circle1.py
new file mode 100644
index 00000000..0813bee2
--- /dev/null
+++ b/Examples/Session07/test_circle1.py
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+
+"""
+code that tests the circle class defined in circle.py
+
+can be run with py.test
+"""
+
+import pytest # used for the exception testing
+
+import math
+
+
+from circle import Circle
+#from circle_solution1 import Circle
+
+
+def test_create():
+ c = Circle(4)
+
+ assert c.radius == 4
+
+
+def test_change_radius():
+ c = Circle(3)
+ c.radius = 4
+
+ assert c.radius == 4
+
+
+def test_diameter():
+ c = Circle(4)
+
+ assert c.diameter == 8
+
+
+def test_change_diameter():
+ c = Circle(2)
+
+ assert c.radius == 2
+ assert c.diameter == 4
+
+ c.diameter = 6
+ assert c.radius == 3
+ assert c.diameter == 6
+
+
+def test_area():
+ c = Circle(4)
+
+ assert c.area == math.pi*16
+
+
+def test_set_area():
+ c = Circle(4)
+
+ with pytest.raises(AttributeError):
+ c.area = 44
+
+
+## the extra credit: classmethod:
+
+# def test_alternate_constructor():
+# c = Circle.from_diameter(8)
+
+# assert c.diameter == 8
+# assert c.radius == 4
diff --git a/Examples/Session07/test_circle2.py b/Examples/Session07/test_circle2.py
new file mode 100644
index 00000000..d70f11d0
--- /dev/null
+++ b/Examples/Session07/test_circle2.py
@@ -0,0 +1,124 @@
+#!/usr/bin/env python
+"""code that tests the circle class defined in circle.py
+
+This version adds more tests
+
+can be run with py.test
+"""
+import math
+import pytest # used for the exception testing
+
+
+from circle import Circle
+
+
+def test_create():
+ c = Circle(4)
+
+ assert c.radius == 4
+
+
+def test_change_radius():
+ c = Circle(3)
+ c.radius = 4
+
+ assert c.radius == 4
+
+
+def test_diameter():
+ c = Circle(4)
+
+ assert c.diameter == 8
+
+
+def test_change_diameter():
+ c = Circle(2)
+
+ assert c.radius == 2
+ assert c.diameter == 4
+
+ c.diameter = 6
+ assert c.radius == 3
+ assert c.diameter == 6
+
+
+def test_area():
+ c = Circle(4)
+
+ assert c.area == math.pi*16
+
+
+def test_set_area():
+ c = Circle(4)
+
+ with pytest.raises(AttributeError):
+ c.area = 44
+
+
+## the extra credit: classmethod:
+
+# def test_alternate_constructor():
+# c = Circle.from_diameter(8)
+
+# assert c.diameter == 8
+# assert c.radius == 4
+
+## the magic methods:
+
+def test_str():
+ c = Circle(3)
+
+ assert str(c) == 'Circle with radius: 3.000000'
+
+
+def test_repr():
+ c = Circle(3)
+
+ assert repr(c) == 'Circle(3)'
+
+
+def test_addition():
+ c1 = Circle(2)
+ c2 = Circle(3)
+ c3 = c1 + c2
+
+ assert c3.radius == 5
+
+
+def test_multiplication():
+ c1 = Circle(2)
+ c3 = c1 * 4
+
+ assert c3.radius == 8
+
+
+def test_equal():
+ c1 = Circle(3)
+ c2 = Circle(3.0)
+
+ assert c1 == c2
+ assert c1 <= c2
+ assert c1 >= c2
+
+
+def test_not_equal():
+ c1 = Circle(2.9)
+ c2 = Circle(3.0)
+
+ assert c1 != c2
+
+
+def test_greater():
+ c1 = Circle(2)
+ c2 = Circle(3)
+
+ assert c2 > c1
+ assert c2 >= c1
+
+
+def test_less():
+ c1 = Circle(2)
+ c2 = Circle(3)
+
+ assert c1 < c2
+ assert c1 <= c2
diff --git a/GeneralNotes/PythonOnWindows.rst b/GeneralNotes/PythonOnWindows.rst
deleted file mode 100644
index 1c9889a6..00000000
--- a/GeneralNotes/PythonOnWindows.rst
+++ /dev/null
@@ -1,276 +0,0 @@
-=========================
-Using Python on Windows
-=========================
-
-Python itself is very platform independent. The code you write will be exactlty the same regardless of platform you are running, unless you want to acess specific system services. However, the tools required to install and work with python and associated packages are somewhat different. Also, as Python comes from, and is mostly used by, the FOSS world, many instructions you will find online are *nix oriented, and many packages are set up and tested primarily on Linux and/or OS-X.
-
-Nevertheless, Python works just fine on Windows once you get yourself properly set up.
-
-The following are few notes that should help you get running on Windows.
-
-[NOTE: these notes are oriented to supporting the UWPCE Certificate in Python Programming classes]
-
-Installing Python
-====================
-
-There are a number of Python distributions out there, some specifically designed to provide a full featured set of packages, often oreinted to scientific programming. These include: Enthought Canopy, Continuum's Anaconda, and Python(xy). However the prome advantage of these sywtems is getting hard-to-build-and-install scientific packages -- they maynot be as useful for the UW certificate program. So we will recommend a more compact route:
-
-python.org binaries
----------------------
-
-We recommend the binary installer available from python.org:
-
-
-
-We are using VErsion 2.7 for this class. Either 32bit or 64bit is fine, although you may have an easier time finding binary packages (see below) for the 32bit version.
-
-setting up the `PATH`
----------------------------
-
-The installer will install to a stardard location, and set itself up in the registry and Start menu. However, for command line use, you will want to put the appropriate locations on your `PATH`. The `PATH` environemnt variable tells the commadn line shell where to look for executables. by adding teh appropriate directory, you can simply type "`python`" on the command line to run python. You will want to add tow directories to the `PATH`::
-
- C:\Python27
- C:\Python27\Scripts
-
-The `Scripts` dir is where Python puts scripts installed by python packages -- ti is very handy to have it on your `PATH` as well.
-
-Add `";C:\Python27;C:\Python27\Scripts"` (without the quotes) to the end of your DOS path environment variable by following the instructions (these are copied from here: )
-
-Instructions
- 1. Click on the Windows "Start" button and then click "Control Panel" from the menu that appears.
- 2. Click "System" in the Windows control panel, then click "Advanced system settings" to open the "System Properties" dialog box.
-
- 3. Click the "Environment Variables" button on the "Advanced" tab of the dialog box.
-
-4. Scroll down in the "System variables" box until you see the "Path" variable. Click on the "Path" entry to highlight, then click the "Edit" button underneath the box.
-
-5. Add a semicolon to the end of the current path line, which is used as a delimiter, and then type the directory path to add. Click "OK" until all the dialog boxes are closed.
-
-6. Restart any open command windows to allow the changeto take effect.
-
-Read more:
-
-Opening a command Window ("DOS box")
---------------------------------------
- a) click Start
- b) click Run...
- c) type "cmd" (without the quotes) in the text entry field
- d) click OK
-
-"Command line here"
----------------------
-"Command line here" is a utility for the file explorer tht lets you open up a command window already set the the vcurrent directory seen in Windows Explorer. A little googling should find it -- it's very handy. (I think it's built in to Windows 7)
-
-
-Installing Packages
-=====================
-
-While python has a "batteries included" philosphy, and there is a lot of great stuff in the standard library, there will come a time when you'll want to use a thord party package (or many of them...)
-
-Python packages come (more or less) in three flavors, in order of difficulty to install.
-
- Pure Python
- Packages that contain only python code are pretty easy -- python is very platfrom independt, so the same code runs everywhere, and there is no need for compilation.
-
- Python and C extension code
- Some packages have some modeuls written in C - known as "extansion modules". These modules need to be compiled for the host system before they can be used.
-
- Python and Extension code with dependencies
- Some packages include not jsut C code, but that C code depends on other third party libraries that do not come with the operating system. Some of these are designed specifically to give python users access to a C lib, and some simply need a given lib to due its job. Examples of comonl used C libs: libpng, libcurl, libfreetype, etc.
-
-distutils
------------
-
-The distutils ("distribution utilities") is a pacakge that comes with all recent version of python -- it provides a standrad and robust way to build, install, and distribute packges. IF you encounter a `setup.py` file, you are using distutils.
-
-Installing from source
-------------------------
-
-Often you will find a package on the web somewhere, and the develper will provide a zip file or tarball of the package source. In this package, there will most likely be a `setup.py file`. To install the package, you simply run teh command::
-
- python setup.py install
-
-You can also build and install in separate steps::
-
- python setup.py build
- python setup.py install
-
-If the package is pure python, this should "just work". However, if the package includes a python extension, it will only work if you have a C compiler installed properly. The best option is Microsoft Visual Studio 2008 (the express addtion is fine, and free). Instaling all that is beyond the scope of this note, but once installed, again, running `setup.py install` should work.
-
-However, if the package contains a module that depends on a third-party libary, then you need to figure out how to build and install that first -- this is not for teh faint of heart, and not recommended for people without experience building software on Windows. Which brings us to:
-
-
-Installing from binaries
---------------------------
-
-As many (most) Windows users do not have (nor know how to use) a compiler, and there is now binary pacakge management system for Windows (like apt-get or rpm for Linux), most pacakge maintainers disribute binaries of their packages for Windows. If they don't, there are often third-party binary packages available. IN this case, they are almost always built for the versions of python available from `python.org`.
-
-At the web site for the pacakge of interest, look for a binary installer (usually a MSI installer). Make sure it is for the python version (2.7) you are running, and (very important!) the bit-depth of your python (32 or 64 bit). For example, wxPython has the following binaries available::
-
- wxPython2.9-win32-py26 32-bit Python 2.6
- wxPython2.9-win64-py26 64-bit Python 2.6
- wxPython2.9-win32-py27 32-bit Python 2.7
- wxPython2.9-win64-py27 64-bit Python 2.7
-
-Make sure you download the correct version, or you will get a cryptic error message.
-
-Once you get it, you can point-and-click install it and you should be good to go.
-
-Binary Repositories
----------------------
-
-There are few repositories of Windows binary pacakges that may have what you are looking for. Msot notable is the repository maintained by Christoph Gohlke: . This is an outstanding resource -- a really remarkable collectin of up to date packages for Windows. Again, be sure to download the version that matches your python installation.
-
-
-`pip` and `easy_install`
-==========================
-
-`pip` and `easy_install` are systems that seek to automatically find a package you are looking for in the python package index (pypi: https://pypi.python.org/pypi) and install them for you. They work great on all systems for pure-python pacakges, but often fail with more complex packages. To install a package::
-
- pip install package_name
-
-as easy as that. `pip` and 'easy_install` also track pacakge dependencies, and try to install them for you as well. It's great when it works.
-
-installing `pip`
----------------
-
-Installing `pip` requires a bit of a "bootstrap" process. First you need to install `setuptools`:. To isntall setuptools, look for the `ez_setup.py` on the setuptools page, download it, and run it::
-
- python ez_setup.py
-
-That should install the latest setuptools. Once that's done, you should be able install pip with easy_install::
-
- easy_install pip
-
-whew! that was harder than it should be.
-
-
-
-2. Add ";C:\Python27;C:\Python27\Scripts" (without the quotes) to the end of your DOS path environment variable. For instructions try:
- http://www.ehow.com/how_7781683_add-path.html
-
-Note: if you already have a cmd window open, you'll need to close and re-open it after doing step 2.
-
-3. Open a cmd window:
- a) click Start
- b) click Run...
- c) type "cmd" (without the quotes) in the text entry field
- d) click OK
-
-4. In the cmd window type: "easy_install swampy" (without the quotes).
-
-
-And two more steps to get iPython and pyreadline:
-
-5. In the cmd window type: "easy_install iPython" (without the quotes).
-
-6. In the cmd window type: "easy_install pyreadline" (without the quotes).
-
-
-
-- - - - - - - - - - - - Step 4. should look like this: - - - - - - - - - - - - -
-
-Microsoft Windows XP [Version 5.1.2600]
-(C) Copyright 1985-2001 Microsoft Corp.
-
-C:\Python27>easy_install swampy
-Searching for swampy
-Reading http://pypi.python.org/simple/swampy/
-Reading http://allendowney.com/swampy
-Best match: swampy 2.1.1
-Downloading http://pypi.python.org/packages/source/s/swampy/swampy-2.1.1.tar.gz#
-md5=a302348a849da33cb454fde993fb9757
-Processing swampy-2.1.1.tar.gz
-Running swampy-2.1.1\setup.py -q bdist_egg --dist-dir c:\docume~1\daniel\locals~
-1\temp\easy_install-q4vdfv\swampy-2.1.1\egg-dist-tmp-gh3rvr
-zip_safe flag not set; analyzing archive contents...
-swampy.Lumpy: module MAY be using inspect.stack
-Adding swampy 2.1.1 to easy-install.pth file
-
-Installed c:\python27\lib\site-packages\swampy-2.1.1-py2.7.egg
-Processing dependencies for swampy
-Finished processing dependencies for swampy
-
-
-
-- - - - - - - - - - - - Step 5. should look like this: - - - - - - - - - - - - -
-
-Microsoft Windows XP [Version 5.1.2600]
-(C) Copyright 1985-2001 Microsoft Corp.
-
-C:\Documents and Settings\Daniel>easy_install iPython
-Searching for iPython
-Reading http://pypi.python.org/simple/iPython/
-Reading http://ipython.scipy.org
-Reading http://ipython.scipy.org/dist
-Reading http://ipython.scipy.org/dist/0.8.4
-Reading http://ipython.scipy.org/dist/0.9.1
-Reading http://ipython.org
-Reading http://archive.ipython.org/release/0.12.1
-Reading https://github.com/ipython/ipython/downloads
-Reading http://ipython.scipy.org/dist/old/0.9
-Reading http://ipython.scipy.org/dist/0.10
-Reading http://archive.ipython.org/release/0.11/
-Reading http://archive.ipython.org/release/0.12
-Best match: ipython 0.13
-Downloading http://pypi.python.org/packages/2.7/i/ipython/ipython-0.13-py2.7.egg
-#md5=694ce5981bf163922bd09617a4742a61
-Processing ipython-0.13-py2.7.egg
-creating c:\python27\lib\site-packages\ipython-0.13-py2.7.egg
-Extracting ipython-0.13-py2.7.egg to c:\python27\lib\site-packages
-Adding ipython 0.13 to easy-install.pth file
-Installing ipcontroller-script.py script to C:\Python27\Scripts
-Installing ipcontroller.exe script to C:\Python27\Scripts
-Installing ipcontroller.exe.manifest script to C:\Python27\Scripts
-Installing iptest-script.py script to C:\Python27\Scripts
-Installing iptest.exe script to C:\Python27\Scripts
-Installing iptest.exe.manifest script to C:\Python27\Scripts
-Installing ipcluster-script.py script to C:\Python27\Scripts
-Installing ipcluster.exe script to C:\Python27\Scripts
-Installing ipcluster.exe.manifest script to C:\Python27\Scripts
-Installing ipython-script.py script to C:\Python27\Scripts
-Installing ipython.exe script to C:\Python27\Scripts
-Installing ipython.exe.manifest script to C:\Python27\Scripts
-Installing pycolor-script.py script to C:\Python27\Scripts
-Installing pycolor.exe script to C:\Python27\Scripts
-Installing pycolor.exe.manifest script to C:\Python27\Scripts
-Installing iplogger-script.py script to C:\Python27\Scripts
-Installing iplogger.exe script to C:\Python27\Scripts
-Installing iplogger.exe.manifest script to C:\Python27\Scripts
-Installing irunner-script.py script to C:\Python27\Scripts
-Installing irunner.exe script to C:\Python27\Scripts
-Installing irunner.exe.manifest script to C:\Python27\Scripts
-Installing ipengine-script.py script to C:\Python27\Scripts
-Installing ipengine.exe script to C:\Python27\Scripts
-Installing ipengine.exe.manifest script to C:\Python27\Scripts
-
-Installed c:\python27\lib\site-packages\ipython-0.13-py2.7.egg
-Processing dependencies for iPython
-Finished processing dependencies for iPython
-
-
-
-- - - - - - - - - - - - Step 6. should look like this: - - - - - - - - - - - - -
-
-Microsoft Windows XP [Version 5.1.2600]
-(C) Copyright 1985-2001 Microsoft Corp.
-
-C:\Documents and Settings\Daniel>easy_install pyreadline
-Searching for pyreadline
-Reading http://pypi.python.org/simple/pyreadline/
-Reading http://ipython.scipy.org/moin/PyReadline/Intro
-Reading https://launchpad.net/pyreadline/+download
-Reading http://projects.scipy.org/ipython/ipython/wiki/PyReadline/Intro
-Best match: pyreadline 2.0-dev1
-Downloading https://launchpad.net/pyreadline/2.0/pyreadline-2.0-prerelease/+down
-load/pyreadline-2.0-dev1.win32.exe
-Processing pyreadline-2.0-dev1.win32.exe
-creating 'c:\docume~1\daniel\locals~1\temp\easy_install-ndbace\pyreadline-2.0_de
-v1-py2.7-win32.egg' and adding 'c:\docume~1\daniel\locals~1\temp\easy_install-nd
-bace\pyreadline-2.0_dev1-py2.7-win32.egg.tmp' to it
-Moving pyreadline-2.0_dev1-py2.7-win32.egg to c:\python27\lib\site-packages
-Adding pyreadline 2.0-dev1 to easy-install.pth file
-
-Installed c:\python27\lib\site-packages\pyreadline-2.0_dev1-py2.7-win32.egg
-Processing dependencies for pyreadline
-Finished processing dependencies for pyreadline
\ No newline at end of file
diff --git a/GeneralNotes/iPythonForWindows.rst b/GeneralNotes/iPythonForWindows.rst
deleted file mode 100644
index afc93590..00000000
--- a/GeneralNotes/iPythonForWindows.rst
+++ /dev/null
@@ -1,69 +0,0 @@
-Installing and Running IPython for Windows:
-###############################
-
-It turns out that iPython works best when there are few other packages installed that it depends on, so it'snot quite as easy as simply instaling the one package.
-
-these re some note put together by Dick Smith -- as he took the time to figure it out, We asked him to write up these notes:
-
-
-Preconditions:
-===================
-
-(see: https://github.com/UWPCE-PythonCert/IntroToPython/blob/master/GeneralNotes/PythonOnWindows.rst for more detail)
-
-Python Interpreter:
---------------------
-32 or 64 bit version of Python for Windows 2.7 installed in C:\Python27\
-(the version found at python.org)
-
-PATH set:
--------------
-MyComputer -> Properties -> Advanced System Settings -> System Variables
-set up appropriately to modify PATH or path and create PYTHONPATH,
-per install instructions.,
-
-Getting packages:
-===================
-Use your web browser to navigate to this URL for downloadable
-Python Windows extension installers recommended by the instructor:
-
-"Unofficial Windows Binaries for Python Extension Packages
-by Christoph Gohlke, Laboratory for Fluorescence Dynamics,
-University of California, Irvine".
-
-http://www.lfd.uci.edu/~gohlke/pythonlibs/
-
-This is not a Git repository. These are Windows-executable installers
-which should be pulled to your PC's download directory.
-
-Single-clicking will start the download process, then executed with a double-click.
-
-NOTE: This repository containt both 32bit and 64bit pacakges -- make sure to get the ones that match the python installed.
-
-Download and run these three installers, in this order:
-
-SetupTools: -- Required by the IPython install script.
-
-setuptools-1.1.6.win32-py2.7.exe
-
-PyReadline: -- Windows extension for adding color (and other nifty features) to the interactive
-presentation.
-
-pyreadline-2.0.win32-py2.7.exe
-
-IPython itself:
-
-ipython-1.1.0.win32-py2.7.exe
-
-Run it by double-clicking on ``C:\Python27\Scripts\ipython.exe``
-
-or typing ``ipython`` on the command line (DOS box)
-
-I recommend making a desktop shortcut and putting that in the target line.
-
-It brings up a commandline console with some initial text about
-resources available via commands, and the Ipython prompt::
-
- IN [1]:
-
-
diff --git a/README.rst b/README.rst
index 37ad4a54..835744c3 100644
--- a/README.rst
+++ b/README.rst
@@ -7,4 +7,9 @@ This repository contains the source materials for the first class in the the Uni
.. _Certificate in Python Programming : http://www.pce.uw.edu/certificates/python-programming.html
-See the Syllabus for more detail, and the individual class notes for the instructional material itself.
\ No newline at end of file
+See the Syllabus for more detail.
+
+Class lecture materials are available in a rendered version from:
+
+http://UWPCE-PythonCert.github.io/IntroToPython
+
diff --git a/Solutions/README.rst b/Solutions/README.rst
new file mode 100644
index 00000000..77cf496c
--- /dev/null
+++ b/Solutions/README.rst
@@ -0,0 +1,4 @@
+This is place for example solutions to the assignments for the CodeFellows Foundations II Python class: sept 2014
+
+Solutions will be added to this directory as the course progresses.
+
diff --git a/Solutions/Session01/print_grid.py b/Solutions/Session01/print_grid.py
new file mode 100755
index 00000000..b341f32b
--- /dev/null
+++ b/Solutions/Session01/print_grid.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+
+"""
+Chris' solution to the week 1 homework problem.
+
+Note that we only did the basics of loops, and you can
+do all this without any loops at all, so that's what I did.
+
+Note also that there is more than one way to skin a cat --
+ or code a function
+"""
+
+
+def print_grid(size):
+ """
+ print a 2x2 grid with a total size of size
+
+ :param size: total size of grid -- it will be rounded if not one more than
+ a multiple of 2
+ """
+ number = 2
+ box_size = int((size-1) // 2) # size of one grid box
+ print "box_size:", box_size
+ # top row
+ top = ('+ ' + '- ' * box_size) * number + '+' + '\n'
+ middle = ('| ' + ' ' * 2 * box_size) * number + '|' + '\n'
+
+ row = top + middle*box_size
+
+ grid = row*number + top
+
+ print grid
+
+
+def print_grid2(number, size):
+ """
+ print a number x number grid with each box of size width and height
+
+ :param number: number of grid boxes (row and column)
+
+ :param size: size of each grid box
+ """
+ # top row
+ top = ('+ ' + '- '*size)*number + '+' + '\n'
+ middle = ('| ' + ' '*2*size)*number + '|' + '\n'
+
+ row = top + middle*size
+
+ grid = row*number + top
+
+ print grid
+
+
+def print_grid3(size):
+ """
+ same as print_grid, but calling print_grid2 to do the work
+ """
+ number = 2
+ box_size = (size-1) / 2 # size of one grid box
+ print_grid2(number, box_size)
+
+
+print_grid(11)
+print_grid(7)
+
+print_grid2(3, 3)
+print_grid2(3, 5)
+
+print_grid3(11)
diff --git a/Students/Dave Fugelso/Lightning Talk/one.py b/Students/Dave Fugelso/Lightning Talk/one.py
new file mode 100644
index 00000000..474ee472
--- /dev/null
+++ b/Students/Dave Fugelso/Lightning Talk/one.py
@@ -0,0 +1,115 @@
+
+original = '''
+518659005232r583491410442e291745698219m421410443129o162080940635v32416189681e64832
+3758660l64832378918a291745692333r648323762540g324161887930e680739944367s22691331914
+3t129664756724p486242827755r648323758580i97248568173m486242846295e421410460783
+'''
+
+originalParsedText = '''
+518659005232
+r
+583491410442
+e
+291745698219
+m
+421410443129
+o
+162080940635
+v
+32416189681
+e
+648323758660
+l
+64832378918
+a
+291745692333
+r
+648323762540
+g
+324161887930
+e
+680739944367
+s
+226913319143
+t
+129664756724
+p
+486242827755
+r
+648323758580
+i
+97248568173
+m
+486242846295
+e
+421410460783
+'''
+
+
+a = '''
+486242831895
+551075217947
+259329507176
+388994275884
+129664751092
+0
+615907574147
+32416188601
+259329512488
+615907584293
+291745691343
+648323773780
+194497138302
+97248563157
+453826655534
+615907594667
+64832376454
+453826635794
+388994273508
+'''
+
+#Code posted on Daniwe.com by a moderators named
+# prime numbers are only divisible by unity and themselves
+# (1 is not considered a prime number by convention)
+def isprime(n):
+ '''check if integer n is a prime'''
+ # make sure n is a positive integer
+ n = abs(int(n))
+ # 0 and 1 are not primes
+ if n < 2:
+ return False
+ # 2 is the only even prime number
+ if n == 2:
+ return True
+ # all other even numbers are not primes
+ if not n & 1:
+ return False
+ # range starts with 3 and only needs to go up the squareroot of n
+ # for all odd numbers
+ for x in range(3, int(n**0.5)+1, 2):
+ if n % x == 0:
+ return False
+ return True
+
+def solve():
+ '''
+ Find out which of the number above are prime
+ '''
+
+ b = a.split()
+ primes = list()
+
+ for line in b:
+ i = int(line)
+ print 'checking', i,
+ if isprime(i):
+ print 'is prime'
+ else:
+ print 'is not prime'
+
+
+
+
+
+
+solve()
\ No newline at end of file
diff --git a/Students/Dave Fugelso/Lightning Talk/prime.py b/Students/Dave Fugelso/Lightning Talk/prime.py
new file mode 100644
index 00000000..f3b7b57b
--- /dev/null
+++ b/Students/Dave Fugelso/Lightning Talk/prime.py
@@ -0,0 +1,128 @@
+
+original = '''
+518659005232r583491410442e291745698219m421410443129o162080940635v32416189681e64832
+3758660l64832378918a291745692333r648323762540g324161887930e680739944367s22691331914
+3t129664756724p486242827755r648323758580i97248568173m486242846295e421410460783
+'''
+
+originalParsedText = '''
+518659005232
+r
+583491410442
+e
+291745698219
+m
+421410443129
+o
+162080940635
+v
+32416189681
+e
+648323758660
+l
+64832378918
+a
+291745692333
+r
+648323762540
+g
+324161887930
+e
+680739944367
+s
+226913319143
+t
+129664756724
+p
+486242827755
+r
+648323758580
+i
+97248568173
+m
+486242846295
+e
+421410460783
+'''
+
+
+nums = '''
+486242831895
+551075217947
+259329507176
+388994275884
+129664751092
+0
+615907574147
+32416188601
+259329512488
+615907584293
+291745691343
+648323773780
+194497138302
+97248563157
+453826655534
+615907594667
+64832376454
+453826635794
+388994273508
+'''
+
+#Code posted on Daniwe.com by a moderators named
+def isprime(n):
+ '''check if integer n is a prime'''
+ # make sure n is a positive integer
+ n = abs(int(n))
+ # 0 and 1 are not primes
+ if n < 2:
+ return n, 'False'
+ # 2 is the only even prime number
+ if n == 2:
+ return 2, 'True'
+ # all other even numbers are not primes
+ if not n & 1:
+ return n/2, 'False'
+ # range starts with 3 and only needs to go up the squareroot of n
+ # for all odd numbers
+ for x in range(3, int(n**0.5)+1, 2):
+ if n % x == 0:
+ return n/x, 'False'
+ return n, 'True'
+
+def solve():
+ '''
+ Process a list of numbers and factor out the largest prime number in each.
+ Add 65 to the number left and convert to a character
+ '''
+
+ numbers = nums.split()
+ largestPrimesGone = list()
+
+ for line in numbers:
+ i = int(line)
+ print 'checking', i
+ n, prime = isprime(i)
+ while prime == 'False' and n > 2:
+ print 'was not prime now checking', n
+ n, prime = isprime(n)
+
+ print 'largest prime is ', n
+ if n != 0:
+ n = i / n
+ print 'new num is ', n
+ largestPrimesGone.append(n)
+
+
+ addr = ''
+ for line in largestPrimesGone:
+ print line
+ addr = addr + str(unichr(line+65))
+
+
+ print addr
+
+
+
+
+
+solve()
diff --git a/Students/Dave Fugelso/Lightning Talk/puzzle listing.png b/Students/Dave Fugelso/Lightning Talk/puzzle listing.png
new file mode 100644
index 00000000..94af8608
Binary files /dev/null and b/Students/Dave Fugelso/Lightning Talk/puzzle listing.png differ
diff --git a/Students/Dave Fugelso/Lightning Talk/two.py b/Students/Dave Fugelso/Lightning Talk/two.py
new file mode 100644
index 00000000..f73a3fd6
--- /dev/null
+++ b/Students/Dave Fugelso/Lightning Talk/two.py
@@ -0,0 +1,120 @@
+original = '''
+518659005232r583491410442e291745698219m421410443129o162080940635v32416189681e64832
+3758660l64832378918a291745692333r648323762540g324161887930e680739944367s22691331914
+3t129664756724p486242827755r648323758580i97248568173m486242846295e421410460783
+'''
+
+originalParsedText = '''
+518659005232
+r
+583491410442
+e
+291745698219
+m
+421410443129
+o
+162080940635
+v
+32416189681
+e
+648323758660
+l
+64832378918
+a
+291745692333
+r
+648323762540
+g
+324161887930
+e
+680739944367
+s
+226913319143
+t
+129664756724
+p
+486242827755
+r
+648323758580
+i
+97248568173
+m
+486242846295
+e
+421410460783
+'''
+
+nums = '''
+486242831895
+551075217947
+259329507176
+388994275884
+129664751092
+0
+615907574147
+32416188601
+259329512488
+615907584293
+291745691343
+648323773780
+194497138302
+97248563157
+453826655534
+615907594667
+64832376454
+453826635794
+388994273508
+'''
+
+
+def isprime(n):
+ '''check if integer n is a prime'''
+ # make sure n is a positive integer
+ n = abs(int(n))
+ # 0 and 1 are not primes
+ if n < 2:
+ return n, False
+ # 2 is the only even prime number
+ if n == 2:
+ return 2, True
+ # all other even numbers are not primes
+ if not n & 1:
+ return n/2, False
+ # range starts with 3 and only needs to go up the squareroot of n
+ # for all odd numbers
+ for x in range(3, int(n**0.5)+1, 2):
+ if n % x == 0:
+ return n/x, False
+ return True
+
+def solve():
+ '''
+ Process a list of numbers and factor out the largest prime number in each.
+ '''
+
+ b = nums.split()
+ primes = list()
+
+ for line in b:
+ i = int(line)
+ print 'checking', i
+ n, prime = isprime(i)
+ while not prime and n > 2:
+ print 'was not prime now checking', n
+ n, prime = isprime(n)
+
+ print 'largest prime is ', n
+ if n != 0:
+ n = i / n
+ print 'new num is ', n
+ primes.append(n)
+
+
+ print 'List is '
+ for n in primes:
+ print n
+
+
+
+
+solve()
\ No newline at end of file
diff --git a/Students/Dave Fugelso/Session 1/breakme.py b/Students/Dave Fugelso/Session 1/breakme.py
new file mode 100644
index 00000000..761583bf
--- /dev/null
+++ b/Students/Dave Fugelso/Session 1/breakme.py
@@ -0,0 +1,33 @@
+'''
+In the break_me.py file write four simple Python functions:
+
+Each function, when called, should cause an exception to happen
+Each function should result in one of the four common exceptions from our lecture.
+for review: NameError, TypeError, SyntaxError, AttributeError
+
+
+Use the Python standard library reference on Built In Exceptions as a reference
+'''
+
+def nameErrorExample():
+ t = somethingThatDoesntExist()
+
+def typeErrorExample ():
+ a = 'Hello, World!'
+ worlds = 1
+ worlds = worlds + a
+
+def syntaxErrorExample ():
+# a = 'some string'
+# a.print()
+ pass
+
+import time
+def attributeErroexample():
+ t = time.time
+ b = t.newtime
+
+#nameErrorExample()
+#typeErrorExample ()
+syntaxErrorExample ()
+attributeErroexample()
\ No newline at end of file
diff --git a/Students/Dave Fugelso/Session 1/grid.py b/Students/Dave Fugelso/Session 1/grid.py
new file mode 100644
index 00000000..1753a208
--- /dev/null
+++ b/Students/Dave Fugelso/Session 1/grid.py
@@ -0,0 +1,121 @@
+'''
+
+Dave Fugelso
+
+Problem:
+
+Write a function that draws a grid like the following:
+
++ - - - - + - - - - +
+| | |
+| | |
+| | |
+| | |
++ - - - - + - - - - +
+| | |
+| | |
+| | |
+| | |
++ - - - - + - - - - +
+Hint: to print more than one value on a line, you can print a comma-separated sequence: print "+ -"
+
+If the sequence ends with a comma, Python leaves the line unfinished, so the value printed next appears on the same line.
+
+print "+",
+print "-"
+The output of these statements is "+ -".
+
+A print statement all by itself ends the current line and goes to the next line.
+
+Part 2:
+
+Write a function print_grid() that takes one integer argument and prints a grid like the picture above, BUT the size of the grid is given by the argument.
+
+For example, print_grid(11) prints the grid in the above picture.
+
+This problem is underspecified. Do something reasonable.
+
+Hints:
+
+A character is a string of length 1
+
+s + t is string s followed by string t
+
+s * n is string s replicated n times
+
+Part 3:
+
+Write a function that draws a similar grid with three rows and three columns.
+
+(what to do about rounding?)
+
+
+
+'''
+
+def cellTopBottom(cells, size):
+ '''
+ print cell top or botton, including the '+'
+ '''
+ for columns in range (0, cells):
+ print '+',
+ for i in range (0, size):
+ print '-',
+ print '+'
+
+def printSide (cells, size):
+ '''
+ Just do the sides, no '+'
+ '''
+
+
+ for rows in range (0, size):
+ print '|',
+ for column in range (0, cells):
+ for spaces in range(0, size):
+ print ' ',
+ print '|',
+ print
+
+def fixed_grid():
+ '''
+ print a two by two grid like example above.
+ '''
+ cells = 2
+ size = 4
+
+ for rows in range(0, cells):
+ cellTopBottom(cells, size)
+ printSide (cells, size)
+ cellTopBottom(cells, size)
+
+def print_grid(size):
+ '''
+ Take an argument and print a grid with a vartiable size
+ '''
+ cells = 2
+
+ for rows in range(0, cells):
+ cellTopBottom(cells, size)
+ printSide (cells, size)
+ cellTopBottom(cells, size)
+
+def print_grid_variable_cells(cells, size):
+ '''
+ Take an argument and print a grid with a variable size
+ Take an argument for number of cells
+
+ Ah, by using cells and size for the cell size I completely missed the rounding portion of this problem.
+ If I did do iut the other way, I would have left off the right and bottom edges.
+ '''
+
+ for rows in range(0, cells):
+ cellTopBottom(cells, size)
+ printSide (cells, size)
+ cellTopBottom(cells, size)
+
+fixed_grid()
+print_grid(4)
+print_grid(5)
+print_grid_variable_cells (3, 4)
+
diff --git a/Students/Dave Fugelso/Session 2/ack.py b/Students/Dave Fugelso/Session 2/ack.py
new file mode 100644
index 00000000..fe6ca666
--- /dev/null
+++ b/Students/Dave Fugelso/Session 2/ack.py
@@ -0,0 +1,79 @@
+'''
+
+Dave Fugelso Python Course homework Session 2 Oct. 9
+
+The Ackermann function, A(m, n), is defined:
+
+A(m, n) =
+ n+1 if m = 0
+ A(m-1, 1) if m > 0 and n = 0
+ A(m-1, A(m, n-1)) if m > 0 and n > 0.
+
+
+
+ See http://en.wikipedia.org/wiki/Ackermann_funciton
+
+Create a new module called ack.py in a session02 folder in your student folder.
+
+In that module, write a function named ack that performs Ackermann's function.
+
+
+Write a good docstring for your function according to PEP 257.
+Ackermanns function is not defined for input values less than 0. Validate inputs to your function and return None if they are negative.
+The wikipedia page provides a table of output values for inputs between 0 and 4. Using this table, add a if __name__ == "__main__": block to test your function.
+
+Test each pair of inputs between 0 and 4 and assert that the result produced by your function is the result expected by the wikipedia table.
+
+When your module is run from the command line, these tests should be executed. If they all pass,
+
+
+print All Tests Pass as the result.
+
+Add your new module to your git clone and commit frequently while working on your implementation. Include good commit messages that explain concisely both what you are doing and why.
+
+When you are finished, push your changes to your fork of the class repository in GitHub. Then make a pull request and submit your assignment in Canvas.
+
+'''
+
+#Ackermann function
+def ack(m, n):
+ '''
+ Calculate the value for Ackermann's function for m, n.
+ '''
+
+ if m < 0 or n < 0: return None
+
+ if m == 0: return n+1
+
+ if n == 0: return ack(m-1, 1)
+
+ return ack (m-1, ack (m, n-1))
+
+
+if __name__ == "__main__":
+ '''
+ Unit test for Ackermann function. Print table m = 0,4 and n = 0,4.
+ '''
+
+ #Print nicely
+ print 'm/n\t\t',
+ for n in range(0,5):
+ print n, '\t',
+ print '\n'
+
+ for m in range (0,4):
+ print m,'\t',
+ for n in range(0,5):
+ print '\t',
+ print ack(m, n),
+ print
+
+ # for the m = 4 row, just print the first one (n = 0) otherwise we hit a stack overflow (maximum resursion)
+ m = 4
+ print m,'\t',
+ for n in range(0,1):
+ print '\t',
+ print ack(m, n),
+ print '\t-\t-\t-\t-'
+
+ print 'All Tests Pass'
\ No newline at end of file
diff --git a/Students/Dave Fugelso/Session 2/series.py b/Students/Dave Fugelso/Session 2/series.py
new file mode 100644
index 00000000..8caeab06
--- /dev/null
+++ b/Students/Dave Fugelso/Session 2/series.py
@@ -0,0 +1,150 @@
+'''
+Dave Fugelso - UW Python Certification 10/09/2014
+
+The Fibonacci Series is a numeric series starting with the integers 0 and 1. In this series, the next
+integer is determined by summing the previous two. This gives us:
+
+0, 1, 1, 2, 3, 5, 8, 13, ...
+Create a new module series.py in the session02 folder in your student folder. In it, add a function
+called fibonacci. The function should have one parameter n. The function should return the nth value in the fibonacci series.
+
+Ensure that your function has a well-formed docstring
+
+The Lucas Numbers are a related series of integers that start with the values 2 and 1 rather than 0 and 1.
+The resulting series looks like this:
+
+
+2, 1, 3, 4, 7, 11, 18, 29, ...
+In your series.py module, add a new function lucas that returns the nth value in the lucas numbers
+
+Ensure that your function has a well-formed docstring
+
+Both the fibonacci series and the lucas numbers are based on an identical formula.
+
+Add a third function called sum_series with one required parameter and two optional parameters. The required
+parameter will determine which element in the series to print. The two optional parameters will have default values of 0 and 1 and will determine the first two values for the series to be produced.
+
+Calling this function with no optional parameters will produce numbers from the fibonacci series. Calling it
+with the optional arguments 2 and 1 will produce values from the lucas numbers. Other values for the optional parameters will produce other series.
+
+Ensure that your function has a well-formed docstring
+
+Add an if __name__ == \"__main__\": block to the end of your series.py module. Use the block to write a series of assert
+statements that demonstrate that your three functions work properly.
+
+
+Use comments in this block to inform the observer what your tests do.
+
+Add your new module to your git clone and commit frequently while working on your implementation. Include good commit
+messages that explain concisely both what you are doing and why.
+
+When you are finished, push your changes to your fork of the class repository in GitHub. Then make a pull request and submit your assignment in Canvas.
+'''
+
+def fibonnacci (n):
+ '''
+ Return the Nth value in the Fibonacci series.
+ Args:
+ n - Nth value
+ '''
+
+ # special cases at front of series
+ if n == 0: return 0
+ if n == 1: return 1
+
+ #else let's calculate
+ a, b = 0, 1
+ for seq in range (2, n):
+ a,b = b,a+b
+ return a+b
+
+def lucas (n):
+ '''
+ Return the Nth value in the Lucas series.
+ Args:
+ n - Nth value
+ '''
+
+ # special cases at front of series
+ if n == 0: return 2
+ if n == 1: return 1
+
+ #else let's calculate
+ a, b = 2, 1
+ for seq in range (2, n):
+ a,b = b,a+b
+ return a+b
+
+'''
+Second solution. Just have lucas and fibonacci start a series function with differing start arguments.
+'''
+
+def series (a, b, n):
+ '''
+ Calculate the nth number in a series based on starting at a, b.
+ Args:
+ a - value for element 0
+ b - value for element 1
+ n - the series element wanted
+ '''
+
+ # special cases at front of series
+ if n == 0: return a
+ if n == 1: return b
+
+ #else let's calculate
+ for seq in range (2, n):
+ a,b = b,a+b
+ return a+b
+
+def fibonacci_2(n):
+ '''
+ Return the Nth value in the Fibonacci series.
+ Args:
+ n - Nth value
+ '''
+ return series(0, 1, n)
+
+def lucas_2(n):
+ '''
+ Return the Nth value in the Lucas series.
+ Args:
+ n - Nth value
+ '''
+ return series(2, 1, n)
+
+if __name__ == "__main__":
+ '''
+ perform unit tests for fibonacci and lucas funcitons.
+ '''
+
+ #Test the Fibinacci series: randomly selected 0, 1 5, 8 and 25
+ assert fibonnacci (0)==0, 'Fibonnaci (0) is 0. Failed!'
+ assert fibonnacci (1)==1, 'Fibonnaci (1) is 1. Failed!'
+ assert fibonnacci (5)==5, 'Fibonnaci (5) is 5. Failed!'
+ assert fibonnacci (8)==21, 'Fibonnaci (8) is 21. Failed!'
+ assert fibonnacci (25)==75025, 'Fibonnaci (25) is 75025. Failed!'
+
+ #Test lucas series: choose 0, 1, 6, 9, 26
+ assert lucas(0)==2, 'Lucas(0) is 2. Failed!'
+ assert lucas(1)==1, 'Lucas(1) is 1. Failed!'
+ assert lucas(6)==18, 'Lucas(6) is 2. Failed!'
+ assert lucas(9)==76, 'Lucas(9) is 2. Failed!'
+ assert lucas(26)==271443, 'Lucas(26) is 2. Failed!'
+
+ #Test the Fibinacci series: randomly selected 0, 1 5, 8 and 25
+ assert fibonnacci_2 (0)==0, 'Fibonnaci 2 (0) is 0. Failed!'
+ assert fibonnacci_2 (1)==1, 'Fibonnaci 2 (1) is 1. Failed!'
+ assert fibonnacci_2 (5)==5, 'Fibonnaci 2 (5) is 5. Failed!'
+ assert fibonnacci_2 (8)==21, 'Fibonnaci 2 (8) is 21. Failed!'
+ assert fibonnacci_2 (25)==75025, 'Fibonnaci 2 (25) is 75025. Failed!'
+
+ # Test the second solutions
+ #Test lucas series: choose 0, 1, 6, 9, 26
+ assert lucas_2(0)==2, 'Lucas 2 (0) is 2. Failed!'
+ assert lucas_2(1)==1, 'Lucas 2 (1) is 1. Failed!'
+ assert lucas_2(6)==18, 'Lucas 2 (6) is 2. Failed!'
+ assert lucas_2(9)==76, 'Lucas 2 (9) is 2. Failed!'
+ assert lucas_2(26)==271443, 'Lucas 2 (26) is 2. Failed!'
+
+
\ No newline at end of file
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/MUST --- missing_char.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/MUST --- missing_char.py
new file mode 100644
index 00000000..f99602d2
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/MUST --- missing_char.py
@@ -0,0 +1,30 @@
+# Question:Given a non-empty string and an int n, return a new string where
+# the char at index n has been removed. The value of n will be a valid index
+# of a char in the original string (i.e. n will be in the range 0..len(str)-1 inclusive).
+#
+# See example below:
+# missing_char('kitten', 1) → 'ktten'
+# missing_char('kitten', 0) → 'itten'
+# missing_char('kitten', 4) → 'kittn'
+
+# My solution
+def missing_char(str, n):
+ strlength = len(str)
+ if n == 0:
+ str1 = str[1:strlength]
+ return str1
+ elif n == strlength:
+ str1 = str[:(strlength-1)]
+ return str1
+ else:
+ str1 = str[0:n] + str[(n+1):strlength]
+ return str1
+# End
+
+# Better solution:
+
+def missing_char(str, n):
+ front = str[:n] # up to but not including n
+ back = str[n+1:] # n+1 through end of string
+ return front + back
+# End
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/diff21.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/diff21.py
new file mode 100644
index 00000000..019208e6
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/diff21.py
@@ -0,0 +1,6 @@
+def diff21(n):
+ if n > 21:
+ return 2*abs(21-n)
+ else:
+ return abs(21-n)
+
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/front3.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/front3.py
new file mode 100644
index 00000000..58e0d024
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/front3.py
@@ -0,0 +1,6 @@
+def front3(str):
+ if len(str) >= 3:
+ return str[:3] + str[:3] + str[:3]
+ else:
+ return str + str + str
+
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/front_back.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/front_back.py
new file mode 100644
index 00000000..efd70bd4
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/front_back.py
@@ -0,0 +1,10 @@
+def front_back(str):
+ if len(str) == 1:
+ return(str)
+ else:
+ front = str[:1]
+ back = str[len(str)-1:]
+ middle = str[1:(len(str)-1)]
+ newstr = back + middle + front
+ return newstr
+
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/makes10.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/makes10.py
new file mode 100644
index 00000000..96b82dfd
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/makes10.py
@@ -0,0 +1,6 @@
+def makes10(a, b):
+ if a == 10 or b == 10 or a + b == 10:
+ return True
+ else:
+ return False
+
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/monkey_trouble.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/monkey_trouble.py
new file mode 100644
index 00000000..0d262783
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/monkey_trouble.py
@@ -0,0 +1,8 @@
+def monkey_trouble(a_smile, b_smile):
+ if a_smile and b_smile:
+ return True
+ elif not a_smile and not b_smile:
+ return True
+ else:
+ return False
+
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/near_hundred.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/near_hundred.py
new file mode 100644
index 00000000..6c71f52a
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/near_hundred.py
@@ -0,0 +1,6 @@
+def near_hundred(n):
+ if (abs(100 - n) <= 10) or (abs(200 - n) <= 10):
+ return True
+ else:
+ return False
+
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/not_string.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/not_string.py
new file mode 100644
index 00000000..24773c31
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/not_string.py
@@ -0,0 +1,5 @@
+def not_string(str):
+ if str.find("not") == 0:
+ return str
+ else:
+ return "not" + " " + str
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/parrot_trouble.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/parrot_trouble.py
new file mode 100644
index 00000000..e645d3bc
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/parrot_trouble.py
@@ -0,0 +1,6 @@
+def parrot_trouble(talking, hour):
+ if talking and (hour < 7 or hour >20):
+ return True
+ else:
+ return False
+
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/pos_neg.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/pos_neg.py
new file mode 100644
index 00000000..19ff5b75
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/pos_neg.py
@@ -0,0 +1,8 @@
+def pos_neg(a, b, negative):
+ if (a < 0 and b > 0 and not negative) or (a > 0 and b < 0 and not negative):
+ return True
+ elif (negative and a < 0 and b < 0):
+ return True
+ else:
+ return False
+
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/sleep_in.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/sleep_in.py
new file mode 100644
index 00000000..8ef2380a
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/sleep_in.py
@@ -0,0 +1,6 @@
+def sleep_in(weekday, vacation):
+ if not weekday or vacation:
+ return True
+ else:
+ return False
+
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/sum_double.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/sum_double.py
new file mode 100644
index 00000000..f94efaa5
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-1/sum_double.py
@@ -0,0 +1,6 @@
+def sum_double(a, b):
+ if a == b:
+ return 2*(a + b)
+ else:
+ return a + b
+
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- Wrong --- arrary123.py~ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- Wrong --- arrary123.py~
new file mode 100644
index 00000000..4ffb5a42
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- Wrong --- arrary123.py~
@@ -0,0 +1,18 @@
+def array123(nums):
+ n = len(nums)
+ if n < 3:
+ return(False)
+ elif n == 3:
+ if nums[0] == 1 and nums[1] == 2 and nums[2] == 3:
+ return(True)
+ else:
+ return(False)
+ elif n > 3:
+ count1 = 0
+ for i in range(0,n-2):
+ if (nums[i] == 1) and (nums[i+1] == 2) and (nums[i+2] == 3):
+ count1 = count1 + 1
+ if count1 >= 1:
+ return(True)
+ else:
+ return(False)
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- Wrong --- last2.py~ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- Wrong --- last2.py~
new file mode 100644
index 00000000..51040e6f
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- Wrong --- last2.py~
@@ -0,0 +1,4 @@
+def last2(str):
+ str1 = str[-2:]
+ n = str.count(str1) -1
+ return(n)
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- arrary123.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- arrary123.py
new file mode 100644
index 00000000..4ffb5a42
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- arrary123.py
@@ -0,0 +1,18 @@
+def array123(nums):
+ n = len(nums)
+ if n < 3:
+ return(False)
+ elif n == 3:
+ if nums[0] == 1 and nums[1] == 2 and nums[2] == 3:
+ return(True)
+ else:
+ return(False)
+ elif n > 3:
+ count1 = 0
+ for i in range(0,n-2):
+ if (nums[i] == 1) and (nums[i+1] == 2) and (nums[i+2] == 3):
+ count1 = count1 + 1
+ if count1 >= 1:
+ return(True)
+ else:
+ return(False)
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- array_count9.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- array_count9.py
new file mode 100644
index 00000000..b45917f3
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- array_count9.py
@@ -0,0 +1,7 @@
+def array_count9(nums):
+ count1 = 0
+ for i in range(len(nums)):
+ if 9 - nums[i] == 0:
+ count1 = count1 + 1
+ return(count1)
+
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- array_front9.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- array_front9.py
new file mode 100644
index 00000000..9baae4cc
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- array_front9.py
@@ -0,0 +1,19 @@
+def array_front9(nums):
+ n = len(nums)
+ count1 = 0
+ if n >= 4:
+ for i in range(4):
+ if 9 - nums[i] == 0:
+ count1 = count1 + 1
+ if count1 >= 1:
+ return(True)
+ else:
+ return(False)
+ else:
+ for i in range(n):
+ if 9 - nums[i] == 0:
+ count1 = count1 + 1
+ if count1 >= 1:
+ return(True)
+ else:
+ return(False)
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- last2.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- last2.py
new file mode 100644
index 00000000..36b30de6
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- last2.py
@@ -0,0 +1,10 @@
+def last2(str):
+ str1 = str[-2:]
+ n = len(str)
+ count1 = 0
+ for i in range(n-1):
+ # only check substring with length 2 from far left to two to far right in the string.
+ if i+2 <= n-1:
+ if str[i:(i+2)] == str1:
+ count1 = count1 + 1
+ return(count1)
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- string_bits.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- string_bits.py
new file mode 100644
index 00000000..8d09becb
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- string_bits.py
@@ -0,0 +1,6 @@
+def string_bits(str):
+ strlength = len(str)
+ newstr = ''
+ for i in range(1,strlength+1,2):
+ newstr = newstr + str[(i-1):i]
+ return(newstr)
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- string_match.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- string_match.py
new file mode 100644
index 00000000..962d67b4
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- string_match.py
@@ -0,0 +1,9 @@
+def string_match(a, b):
+ count1 = 0
+ n = max(len(a),len(b))
+ for i in range(n-1):
+ if i+1 <= len(a) and i+1 <= len(b):
+ if a[i:(i+2)] == b[i:(i+2)]:
+ count1 = count1 + 1
+ return(count1)
+
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- string_splosion.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- string_splosion.py
new file mode 100644
index 00000000..5caf3c0a
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/MUST --- string_splosion.py
@@ -0,0 +1,9 @@
+def string_splosion(str):
+ newstr = str
+ newstr2 = str
+ strlength = len(str)
+ for i in range(1,strlength+1):
+ newstr1 = newstr[:(strlength - i)]
+ newstr2 = newstr1+ newstr2
+ return(newstr2)
+
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/array123-test.py~ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/array123-test.py~
new file mode 100644
index 00000000..0bdf5ffe
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/array123-test.py~
@@ -0,0 +1,20 @@
+def array123(nums):
+ print nums
+ n = len(nums)
+ print n
+ count1 = 0
+ for i in range(0,3):
+ if (nums[i] == 1) and (nums[i+1] == 2) and (nums[i+2] == 3):
+ print i
+ print nums[i], nums[i+1], nums[i+2]
+ count1 = count1 + 1
+ if count1 >= 1:
+ print count1
+ return(True)
+ else:
+ print count1
+ return(True)
+
+array123([1, 1, 2, 3, 1])
+
+
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/front_times.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/front_times.py
new file mode 100644
index 00000000..3005fb21
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/front_times.py
@@ -0,0 +1,5 @@
+def front_times(str, n):
+ if len(str) >= 3:
+ return(n*str[:3])
+ else:
+ return(n*str)
diff --git a/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/string_times.py b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/string_times.py
new file mode 100644
index 00000000..7a389f82
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/CodingBat/Warmup-2/string_times.py
@@ -0,0 +1,3 @@
+def string_times(str, n):
+ return(n*str)
+
diff --git a/Students/Hui Zhang/Session 1/break_me.py b/Students/Hui Zhang/Session 1/break_me.py
new file mode 100644
index 00000000..1509e671
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/break_me.py
@@ -0,0 +1,98 @@
+-------------
+-------------
+Create a funtcion to trigger AttributeError
+
+def testatterror():
+ n = 5
+ n.append(4)
+ print n
+ .....:
+
+In [104]: testatterror()
+---------------------------------------------------------------------------
+AttributeError Traceback (most recent call last)
+ in ()
+----> 1 testatterror()
+
+ in testatterror()
+ 1 def testatterror():
+ 2 n = 5
+----> 3 n.append(4)
+ 4 print n
+ 5
+
+AttributeError: 'int' object has no attribute 'append'
+
+In [105]:
+
+
+
+
+-------------
+-------------
+Create a funtcion to trigger TypeError
+
+
+def testtypeerror():
+ n = '5'
+ m = 5
+ mn = m + n
+ print mn
+ ....:
+
+In [99]: testtypeerror()
+---------------------------------------------------------------------------
+TypeError Traceback (most recent call last)
+ in ()
+----> 1 testtypeerror()
+
+ in testtypeerror()
+ 7 n = '5'
+ 8 m = 5
+----> 9 mn = m + n
+ 10 print mn
+ 11
+
+TypeError: unsupported operand type(s) for +: 'int' and 'str'
+
+In [100]:
+
+
+
+
+-------------
+-------------
+Create a funtcion to trigger NameError
+def testnameerror():
+ print nn
+
+
+In [89]: testnameerror()
+---------------------------------------------------------------------------
+NameError Traceback (most recent call last)
+ in ()
+----> 1 testnameerror()
+
+ in testnameerror()
+ 1 def testnameerror():
+----> 2 print nn
+ 3
+
+NameError: global name 'nn' is not defined
+
+
+
+
+-------------
+-------------
+Create a function to trigger SyntaxError
+
+def testnameerror()
+ print n
+
+In [85]: def testnameerror()
+ File "", line 1
+ def testnameerror()
+ ^
+SyntaxError: invalid syntax
+
diff --git a/Students/Hui Zhang/Session 1/fungrid-p1.py b/Students/Hui Zhang/Session 1/fungrid-p1.py
new file mode 100644
index 00000000..91319efb
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/fungrid-p1.py
@@ -0,0 +1,8 @@
+# my fungrid
+def fungrid():
+ for i in range(0, 2):
+ print'+ - - - - + - - - - +'
+ for n in range(0, 4):
+ print'| | |'
+ print'+ - - - - + - - - - +'
+fungrid()
diff --git a/Students/Hui Zhang/Session 1/fungrid-p2.py b/Students/Hui Zhang/Session 1/fungrid-p2.py
new file mode 100644
index 00000000..9a0efeeb
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/fungrid-p2.py
@@ -0,0 +1,9 @@
+# my fungrid
+n = input('Please input your number:' )
+def fungrid():
+ for i in range(0, 2):
+ print '+' + n*'-' + '+' + n*'-' + '+'
+ for m in range(0, n):
+ print '|' + n*' ' + '|' + n*' ' + '|'
+ print '+' + n*'-' + '+' + n*'-' + '+'
+fungrid()
\ No newline at end of file
diff --git a/Students/Hui Zhang/Session 1/fungrid-p3.py b/Students/Hui Zhang/Session 1/fungrid-p3.py
new file mode 100644
index 00000000..31f3aca5
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/fungrid-p3.py
@@ -0,0 +1,9 @@
+# my fungrid
+n = input('Please input your number:' )
+def fungrid():
+ for i in range(0, 3):
+ print '+' + n*'-' + '+' + n*'-' + '+' + n*'-' + '+'
+ for m in range(0, n):
+ print '|' + n*' ' + '|' + n*' ' + '|' + n*' ' + '|'
+ print '+' + n*'-' + '+' + n*'-' + '+' + n*'-' + '+'
+fungrid()
\ No newline at end of file
diff --git a/Students/Hui Zhang/Session 1/fungrid.py b/Students/Hui Zhang/Session 1/fungrid.py
new file mode 100644
index 00000000..91319efb
--- /dev/null
+++ b/Students/Hui Zhang/Session 1/fungrid.py
@@ -0,0 +1,8 @@
+# my fungrid
+def fungrid():
+ for i in range(0, 2):
+ print'+ - - - - + - - - - +'
+ for n in range(0, 4):
+ print'| | |'
+ print'+ - - - - + - - - - +'
+fungrid()
diff --git a/Students/Hui Zhang/session02/ack.py b/Students/Hui Zhang/session02/ack.py
new file mode 100644
index 00000000..d89b2ecd
--- /dev/null
+++ b/Students/Hui Zhang/session02/ack.py
@@ -0,0 +1,18 @@
+def ack(m, n):
+ if m == 0:
+ return(n + 1)
+ elif m > 0 and n == 0:
+ return ack(m - 1, 1)
+ elif m > 0 and n > 0:
+ return ack(m -1, ack(m, n - 1))
+
+if __name__ == "__main__":
+ # execute only if run as a script
+ main()
+ #for m in range(0, 5):
+ # for n in range(0, 5):
+ # ack(m, n)
+ # print n + 1
+ #print "All Tests Pass"
+
+
diff --git a/Students/Hui Zhang/session02/series.pyc b/Students/Hui Zhang/session02/series.pyc
new file mode 100644
index 00000000..05a6bedb
Binary files /dev/null and b/Students/Hui Zhang/session02/series.pyc differ
diff --git a/Students/Hui Zhang/session02/test-ack.py b/Students/Hui Zhang/session02/test-ack.py
new file mode 100644
index 00000000..27713358
--- /dev/null
+++ b/Students/Hui Zhang/session02/test-ack.py
@@ -0,0 +1,48 @@
+from ack import ack
+
+
+count1 = 0
+if ack(0, 0) == 1:
+ count1 = count1 + 1
+if ack(1, 0) == 2:
+ count1 = count1 + 1
+if ack(2, 0) == 3:
+ count1 = count1 + 1
+if ack(3, 0) == 5:
+ count1 = count1 + 1
+if ack(0, 1) == 2:
+ count1 = count1 + 1
+if ack(1, 1) == 3:
+ count1 = count1 + 1
+if ack(2, 1) == 5:
+ count1 = count1 + 1
+if ack(3, 1) == 13:
+ count1 = count1 + 1
+if ack(0, 2) == 3:
+ count1 = count1 + 1
+if ack(1, 2) == 4:
+ count1 = count1 + 1
+if ack(2, 2) == 7:
+ count1 = count1 + 1
+if ack(3, 2) == 29:
+ count1 = count1 + 1
+if ack(0, 3) == 4:
+ count1 = count1 + 1
+if ack(1, 3) == 5:
+ count1 = count1 + 1
+if ack(2, 3) == 9:
+ count1 = count1 + 1
+if ack(3, 3) == 61:
+ count1 = count1 + 1
+if ack(0, 4) == 5:
+ count1 = count1 + 1
+if ack(1, 4) == 6:
+ count1 = count1 + 1
+if ack(2, 4) == 11:
+ count1 = count1 + 1
+if ack(3, 4) == 125:
+ count1 = count1 + 1
+
+if count1 == 20:
+ print "All Tests Pass"
+
diff --git a/Students/RPerkins/session01/break_me.py b/Students/RPerkins/session01/break_me.py
new file mode 100644
index 00000000..0f72fdd5
--- /dev/null
+++ b/Students/RPerkins/session01/break_me.py
@@ -0,0 +1,14 @@
+def NameWrong():
+ d = seven
+ return
+def TypeWrong():
+ f = 14.2
+ len(f)
+ return
+def SyntaxWrong():
+ x = len("four
+ return
+def AtrribWrong():
+ f = "1234"
+ f.rocket
+ return
diff --git a/Students/RPerkins/session01/grid_build.py b/Students/RPerkins/session01/grid_build.py
new file mode 100644
index 00000000..0a5b7a16
--- /dev/null
+++ b/Students/RPerkins/session01/grid_build.py
@@ -0,0 +1,31 @@
+def Rowline(size, column):
+# prints an "x", then a number of "-"s (scaled by the "size" parameter),
+# for each count of the "column" parameter
+ for i in range(column):
+ print "+",
+ for x in range(4 + (size-1)):
+ print "-",
+ print "+" # the "bookend" character
+ return
+
+def Columnline(size, column):
+# prints an "|", then a number of " "s (scaled by the "size" parameter),
+# for each count of the "column" parameter
+ for i in range(column):
+ print "|",
+ for x in range(4 + (size-1)):
+ print " ",
+ print "|" # the "bookend" character
+ return
+
+def PrintGrid(size, row, column):
+# the outer loop prints a "row" number of rowlines
+# the inner loop prints a number of column lines scaled
+# by the "size" parameter
+ for i in range(row):
+ Rowline(size, column)
+ for i in range(4 + (size-1)):
+ Columnline(size, column)
+ Rowline(size, column) # the "bookend" row
+
+PrintGrid(1,2,2)
\ No newline at end of file
diff --git a/Students/RPerkins/session02/ack.py b/Students/RPerkins/session02/ack.py
new file mode 100644
index 00000000..d54b896e
--- /dev/null
+++ b/Students/RPerkins/session02/ack.py
@@ -0,0 +1,46 @@
+__author__ = 'Robert W. Perkins'
+
+
+def ack(m, n):
+ """Return the result of the Ackermann function on m and n"""
+ if m < 0 or n < 0:
+ return None
+ elif m == 0:
+ return n+1
+ elif m > 0 and n == 0:
+ return ack(m-1, 1)
+ elif m > 0 and n > 0:
+ return ack(m-1, ack(m, n-1))
+
+# Testing Block
+if __name__ == "__main__":
+ assert ack(-1, 2) is None
+ assert ack(2, -1) is None
+ assert ack(-1, -1) is None
+ assert ack(0, 0) == 1
+ assert ack(0, 1) == 2
+ assert ack(0, 2) == 3
+ assert ack(0, 3) == 4
+ assert ack(0, 4) == 5
+ assert ack(1, 0) == 2
+ assert ack(1, 1) == 3
+ assert ack(1, 2) == 4
+ assert ack(1, 3) == 5
+ assert ack(1, 4) == 6
+ assert ack(2, 0) == 3
+ assert ack(2, 1) == 5
+ assert ack(2, 2) == 7
+ assert ack(2, 3) == 9
+ assert ack(2, 4) == 11
+ assert ack(3, 0) == 5
+ assert ack(3, 1) == 13
+ assert ack(3, 2) == 29
+ assert ack(3, 3) == 61
+ assert ack(3, 4) == 125
+ # max recursion depth exceeded after this point
+ #assert ack(4, 0) == 2**2**2-3
+ #assert ack(4, 1) == 2**2**2**2-3
+ #assert ack(4, 2) == (2**65536)-3
+ #assert ack(4, 3) == (2**2**65536)-3
+ #assert ack(4, 4) == (2**2**2**65536)-3
+ print 'All tests passed'
\ No newline at end of file
diff --git a/Students/RPerkins/session02/series.py b/Students/RPerkins/session02/series.py
new file mode 100644
index 00000000..041742a8
--- /dev/null
+++ b/Students/RPerkins/session02/series.py
@@ -0,0 +1,93 @@
+__author__ = 'Robert W. Perkins'
+
+
+def fibonacci(n):
+ """Return the 'n'th value in the Fibonacci series"""
+
+# test for input in valid range
+ if n < 0:
+ return None
+
+# test for n == 0
+ if n == 0:
+ return 0
+
+# base case is n == 1
+ if n == 1:
+ return 1
+ else:
+ return fibonacci(n-1) + fibonacci(n-2)
+
+def lucas(n):
+ """Return the 'n'th value in the Lucas number series"""
+
+# test for input in valid range
+ if n < 0:
+ return None
+
+# test for n == 0
+ if n == 0:
+ return 2
+
+# base case is n == 1
+ if n == 1:
+ return 1
+ else:
+ return lucas(n-1) + lucas(n-2)
+
+def sum_series(n,first=0,second=1):
+ """Return the 'n'th value of a variable series"""
+
+ """The first two numbers are passed via "first" and "second"
+ and each subsequent element is the sum of the 'n-1'th and 'n-2'th element (yes, i said tooth)"""
+
+# test for input in valid range
+ if n < 0:
+ return None
+
+# test for n == 0
+ if n == 0:
+ return first
+
+# base case is n == 1
+ if n == 1:
+ return second
+ else:
+ return sum_series(n-1,first,second) + sum_series(n-2,first,second)
+
+
+# Testing Block
+if __name__ == "__main__":
+
+ # test fibonacci function for out of range, n == zero, base case, and 18th value in series
+ assert fibonacci(-3) is None
+ assert fibonacci(0) == 0
+ assert fibonacci(1) == 1
+ assert fibonacci(17) == 1597
+
+ # test lucas function for out of range, n == zero, base case, and 11th value in series
+ assert lucas(-3) is None
+ assert lucas(0) == 2
+ assert lucas(1) == 1
+ assert lucas(10) == 123
+
+ # tests sum_series function for fibonacci behavior with no optional params
+ # for out of range, n == zero, base case, and 18th value in series
+ assert sum_series(-3) is None
+ assert sum_series(0) == 0
+ assert sum_series(1) == 1
+ assert sum_series(17) == 1597
+
+ # tests sum_series function for lucas behavior with lucas series params
+ # for out of range, n == zero, base case, and 11th value in series
+ assert sum_series(-3,2,1) is None
+ assert sum_series(0,2,1) == 2
+ assert sum_series(1,2,1) == 1
+ assert sum_series(10,2,1) == 123
+
+ # tests sum_series function for valid results with optional params
+ # for out of range, n == zero, base case, and 11th value in series
+ assert sum_series(-3,4,2) is None
+ assert sum_series(0,4,2) == 4
+ assert sum_series(1,4,2) == 2
+ assert sum_series(10,4,2) == 246
\ No newline at end of file
diff --git a/Students/Readme.rst b/Students/Readme.rst
new file mode 100644
index 00000000..aea97a11
--- /dev/null
+++ b/Students/Readme.rst
@@ -0,0 +1,10 @@
+This is a dir for student's work.
+
+If you want to put your work here for review:
+
+* "fork" this repository in gitHub (make a copy in your own gitHub account)
+* Create a directoy in this directory with your name
+* put your work in that directory in some organised fashion
+* commit those changes to your gitHub repo
+* submit a "pull request"
+
diff --git a/Students/SSchwafel/test.py b/Students/SSchwafel/test.py
new file mode 100644
index 00000000..e69de29b
diff --git a/Students/imdavis/lightningTalk.pdf b/Students/imdavis/lightningTalk.pdf
new file mode 100644
index 00000000..bed57293
Binary files /dev/null and b/Students/imdavis/lightningTalk.pdf differ
diff --git a/Students/imdavis/session01/buildgrid.py b/Students/imdavis/session01/buildgrid.py
new file mode 100644
index 00000000..00e9c5b5
--- /dev/null
+++ b/Students/imdavis/session01/buildgrid.py
@@ -0,0 +1,26 @@
+# a function which takes on a single argument defining the size
+# of a grid to draw
+
+def print_grid(gridsize):
+ # define the top and bottom portion of a single grid cell
+ corner = "+"
+ midtopbot = 4 * "-"
+
+ # define the center of a single grid cell
+ gridcenter = "|" + 4 * " "
+
+ # define how to draw the complete top, bottom, and middle of the
+ # full grid in a single direction
+ topbot = gridsize * (corner + midtopbot) + corner
+ center = gridsize * gridcenter + "|"
+
+ # build the grid in one direction
+ onedirgrid = topbot + "\n"
+ onedirgrid += 4 * (center + "\n")
+
+ #build the full grid
+ grid = gridsize * onedirgrid + topbot
+
+ # now print the grid
+ print grid
+
diff --git a/Students/imdavis/session01/drawgrid.py b/Students/imdavis/session01/drawgrid.py
new file mode 100644
index 00000000..e66fd49e
--- /dev/null
+++ b/Students/imdavis/session01/drawgrid.py
@@ -0,0 +1,10 @@
+# draws a grid using the buildgrid function after prompting the
+# user for the size of the grid
+
+import buildgrid
+
+try:
+ size = int(raw_input("What size grid would you like to build? "))
+ buildgrid.print_grid(size)
+except ValueError:
+ print "Please enter an integer!"
\ No newline at end of file
diff --git a/Students/imdavis/session02/ack.py b/Students/imdavis/session02/ack.py
new file mode 100755
index 00000000..f428daf3
--- /dev/null
+++ b/Students/imdavis/session02/ack.py
@@ -0,0 +1,78 @@
+#!/usr/bin/env python2.7
+# -*- coding: utf-8 -*-
+
+"""Example of a recursive function with a good docstring.
+
+For best results to view the docstring, after importing do:
+
+ >>> print ack.__doc__
+
+Its value grows rapidly, even for small inputs. For example A(4,2) is an
+integer of 19,729 decimal digits. May hit maximum recursion limit. See:
+
+ sys.getrecursionlimit()
+ sys.setrecursionlimit()
+
+"""
+
+def ack(m, n):
+ """Evaluation of the Ackermann Function.
+
+ The Ackermann Function is defined as:
+ A(m, n) =
+ n+1 if m = 0
+ A(m−1, 1) if m > 0 and n = 0
+ A(m−1, A(m, n−1)) if m > 0 and n > 0
+
+ Args:
+ m (int): must be >= 0
+ n (int): must be >= 0.
+
+ Yields:
+ Evaluation of Ackermann function for A(m, n)
+
+ """
+
+ if (m < 0 or n < 0):
+ print "Arguments for the Ackermann function must be >= 0."
+ return None
+ elif (m == 0):
+ return n + 1
+ elif (n == 0):
+ return ack(m - 1, 1)
+ else:
+ return ack(m - 1, ack(m, n - 1))
+
+if __name__ == '__main__':
+ TestsPass = True
+
+ try:
+ assert ack(0, 0) == 1
+ assert ack(0, 1) == 2
+ assert ack(0, 2) == 3
+ assert ack(0, 3) == 4
+ assert ack(0, 4) == 5
+ assert ack(1, 0) == 2
+ assert ack(1, 1) == 3
+ assert ack(1, 2) == 4
+ assert ack(1, 3) == 5
+ assert ack(1, 4) == 6
+ assert ack(2, 0) == 3
+ assert ack(2, 1) == 5
+ assert ack(2, 2) == 7
+ assert ack(2, 3) == 9
+ assert ack(2, 4) == 11
+ assert ack(3, 0) == 5
+ assert ack(3, 1) == 13
+ assert ack(3, 2) == 29
+ assert ack(3, 3) == 61
+ assert ack(3, 4) == 125
+ assert ack(4, 0) == 13
+
+ except AssertionError:
+ TestsPass = False
+ print "All Tests Did Not Pass!"
+
+ if (TestsPass):
+ print "All Tests Pass!"
+
diff --git a/Students/imdavis/session02/series.py b/Students/imdavis/session02/series.py
new file mode 100755
index 00000000..69b7b434
--- /dev/null
+++ b/Students/imdavis/session02/series.py
@@ -0,0 +1,127 @@
+#!/usr/bin/env python2.7
+# -*- coding: utf-8 -*-
+
+def fibonacci(n):
+ """Evaluation of the nth term of the Fibonnaci Series.
+
+ The Fibonnaci Series is defined as:
+ 0th term: 0
+ 1st term: 1
+ nth term: sum of previous two terms in the series
+
+ Args:
+ n (int): nth term in series (must be >= 0)
+
+ Yields:
+ nth term of the Fibonnaci Series.
+
+ """
+
+ if (n < 0):
+ print "Arguments for the Fibonnaci series must be >= 0."
+ return None
+ elif (n == 0): # zeroth term = 0
+ return 0
+ elif (n == 1): # first term = 1
+ return 1
+ else:
+ return fibonacci(n - 1) + fibonacci(n - 2)
+
+def lucas(n):
+ """Evaluation of the nth term of the Lucas Series.
+
+ The Lucas Series is defined as:
+ 0th term: 2
+ 1st term: 1
+ nth term: sum of previous two terms in the series
+
+ Args:
+ n (int): nth term in series (must be >= 0)
+
+ Yields:
+ nth term of the Lucas Series.
+
+ """
+
+ if (n < 0):
+ print "Arguments for the Lucas series must be >= 0."
+ return None
+ elif (n == 0): # zeroth term = 0
+ return 2
+ elif (n == 1): # first term = 1
+ return 1
+ else:
+ return lucas(n - 1) + lucas(n - 2)
+
+def sum_series(n, zerothTerm=0, firstTerm=1):
+ """Evaluation of the nth term of a series.
+
+ This function will return the nth term in a series which is the sum
+ of the previous two consecutive terms in the series. The user can
+ specify any zeroth and first terms to define the series, or can use
+ the default values of 0 and 1 to give the n-th term of the
+ Fibonacci series.
+
+ Args:
+ n (int): nth term in series (must be >= 0)
+ zerothTerm (int): zeroth term in the series (default = 0)
+ firstTerm (int): first term in the series (default = 1)
+
+ Yields:
+ nth term of the series.
+
+ """
+
+ if (n < 0):
+ print "Arguments for the series must be >= 0."
+ return None
+ elif (n == 0):
+ return zerothTerm
+ elif (n == 1):
+ return firstTerm
+ else:
+ return sum_series(n - 1, zerothTerm, firstTerm) + sum_series(n - 2, zerothTerm, firstTerm)
+
+
+if __name__ == '__main__':
+ FibanocciTestsPass = True
+ LucasTestsPass = True
+ ArbitrarySeriesTestsPass = True
+
+ # Some assertions to test the Fibonacci series function against known solutions
+ try:
+ assert fibonacci(0) == 0
+ assert fibonacci(1) == 1
+ assert fibonacci(10) == 55
+ assert fibonacci(19) == 4181
+
+ except AssertionError:
+ FibanocciTestsPass = False
+ print "All Fibonacci Tests Did Not Pass!"
+
+ # Some assertions to test the Lucas series function against known solutions
+ try:
+ assert lucas(0) == 2
+ assert lucas(1) == 1
+ assert lucas(10) == 123
+ assert lucas(20) == 15127
+
+ except AssertionError:
+ LucasTestsPass = False
+ print "All Lucas Tests Did Not Pass!"
+
+ # Some assertions to test the arbitrary series function against known solutions
+ try:
+ assert sum_series(10) == 55
+ assert sum_series(10, 0, 1) == 55
+ assert sum_series(10, 2, 1) == 123
+ assert sum_series(15, 3, 3) == 2961
+ assert sum_series(20, 5, 2) == 34435
+ assert sum_series(20, 2, 5) == 42187
+
+ except AssertionError:
+ ArbitrarySeriesTestsPass = False
+ print "All aritrary series tests did not pass"
+
+ if (FibanocciTestsPass and LucasTestsPass and ArbitrarySeriesTestsPass):
+ print "All Tests Pass!"
diff --git a/Students/salim/draw_box.py b/Students/salim/draw_box.py
new file mode 100644
index 00000000..1ca1d70c
--- /dev/null
+++ b/Students/salim/draw_box.py
@@ -0,0 +1,74 @@
+def print_grid(size, boxes):
+
+ # adjust wrong inputs
+ size, boxes = adjust_inputs(size, boxes)
+
+ # rows of grid
+ row_count = 0
+ for i in range(size):
+
+ # if row is a solid line
+ if row_count % (size / boxes) == 0:
+
+ print_row(width=size, row_type='solid', boxes=boxes)
+
+ # if row is a non-solid line
+ else:
+
+ print_row(width=size, row_type='non-solid', boxes=boxes)
+
+ # increment row_count
+ row_count += 1
+
+
+def print_row(width, row_type, boxes):
+
+ # set row type
+ if row_type == 'solid':
+ outside = '+'
+ inside = '-'
+ elif row_type == 'non-solid':
+ outside = '|'
+ inside = ' '
+
+ # columns of row
+ col_count = 0
+ for ii in range(width):
+
+ # if middle of row
+ if col_count < (width - 1):
+
+ if col_count % (width / boxes) == 0:
+ print outside, # include commas to keep text on same line
+ else:
+ print inside, # include commas to keep text on same line
+
+ # if end of row
+ else:
+
+ if col_count % (width / boxes) == 0 or boxes == 1:
+ print outside
+ else:
+ print inside
+
+ # increment col_count
+ col_count += 1
+
+
+def adjust_inputs(size, boxes):
+
+ # if size input is even, change to next biggest odd number
+ if size % 2 == 0:
+ size_result = size + 1
+ else:
+ size_result = size
+
+ # min of boxes value 1 and boxes value not greater than size_result
+ if boxes <= 1:
+ boxes_result = 1
+ elif boxes > size_result:
+ boxes_result = size_result
+ else:
+ boxes_result = boxes
+
+ return size_result, boxes_result
diff --git a/Syllabus.rst b/Syllabus.rst
index 9e4ff116..e53c7b0d 100644
--- a/Syllabus.rst
+++ b/Syllabus.rst
@@ -70,11 +70,11 @@ gitHub:
All class materials will be up on gitHub (where you probably found this). This allows me to update things at the last minute, and the students can all have easy access to the latest versions. It also familiarizes you with a very useful tool for software development. We'll spend a bit of time during the first class getting everyone up and running with git....
-_
+https://github.com/UWPCE-PythonCert/IntroToPython
for rendered and ready to read version:
-
+http://UWPCE-PythonCert.github.io/IntroToPython
Reading:
========
diff --git a/lightning_schedule.txt b/lightning_schedule.txt
new file mode 100644
index 00000000..2810ff3e
--- /dev/null
+++ b/lightning_schedule.txt
@@ -0,0 +1,35 @@
+week 2: Chantal Huynh
+week 2: David Fugelso
+week 2: Ian M Davis
+week 2: Schuyler Alan Schwafel
+week 3: James Brent Nunn
+week 3: Lauren Fries
+week 3: Lesley D Reece
+week 3: Michel Claessens
+week 4: Benjamin C Mier
+week 4: Robert W Perkins
+week 4: Vinay Gupta
+week 4: Wayne R Fukuhara
+week 5: Darcy Balcarce
+week 5: Eric Buer
+week 5: Henry B Fischer
+week 5: Kyle R Hart
+week 6: Aleksey Kramer
+week 6: Alexander R Galvin
+week 6: Gideon I Sylvan
+week 6: Hui Zhang
+week 7: Andrew P Klock
+week 7: Danielle G Marcos
+week 7: Ousmane Conde
+week 7: Salim Hassan Hamed
+week 8: Alireza Hashemloo
+week 8: Arielle R Simmons
+week 8: Eric W Westman
+week 8: Ryan J Albright
+week 9: Alexandra N Kazakova
+week 9: Erik Ivan Lottsfeldt
+week 9: Louis John Ascoli
+week 9: Ralph P Brand
+week 10: Bryan L Davis
+week 10: Carolyn J Evans
+week 10: Changqing Zhu
diff --git a/slides_sources/ToDo.txt b/slides_sources/ToDo.txt
new file mode 100644
index 00000000..f8c1dc38
--- /dev/null
+++ b/slides_sources/ToDo.txt
@@ -0,0 +1,35 @@
+Things to do for the UWPCE INtro to Python class:
+
+For Session 2:
+
+Note: I decided to not confuse things with unicode off teh bat --
+so I'm stripping the 'u' from string literals wherever I find them.
+
+[x] Update presentaion for UWPCE instead of CodeFellows
+[x] - mention of CodeFellows
+[x] - urls for git
+
+[x] Add outline of class to beginning of slides
+
+[x] Add section breaks to slides for LAB time and lightning talks:
+ some lecture
+ some lab time
+ two lightning talks
+
+[ ] General slide proofread and clean up for layout, etc.
+
+I think we shouod remove the parameter unpacking: *args and **kwargs --
+too much when you don't really know what a tuple or dict is...
+
+[x] Remove parameter unpacking
+
+[ ] Add more to the function lab -- should be 20min or so of work.
+ - they have learned about returning multiple values.
+
+[ ] Put in solution to this weeks homework in Solutions
+ --Chris has soem kicking around to find...
+
+
+Future Sessions:
+
+Add discusion of parameter unpacking: *args and **kwargs
diff --git a/slides_sources/build_gh_pages.sh b/slides_sources/build_gh_pages.sh
new file mode 100755
index 00000000..f03a5a03
--- /dev/null
+++ b/slides_sources/build_gh_pages.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# simple script to build and push to gh-pages
+# designed to be run from master
+
+# make the docs
+make html
+
+# copy to other repo (on the gh-pages branch)
+cp -R build/html/ ../../IntroToPython.gh-pages
+
+cd ../../IntroToPython.gh-pages
+git add * # in case there are new files added
+git commit -a
+git push
diff --git a/slides_sources/requirements.txt b/slides_sources/requirements.txt
index 69243dbf..4666c460 100644
--- a/slides_sources/requirements.txt
+++ b/slides_sources/requirements.txt
@@ -4,3 +4,8 @@ Pygments==1.6
Sphinx==1.2.2
docutils==0.11
sphinx-rtd-theme==0.1.6
+gnureadline==6.2.5
+# hieroglyph==0.7.dev
+-e git+https://github.com/nyergler/hieroglyph.git#egg=hieroglyph
+ipython==2.3.0
+libsass==0.5.1
diff --git a/slides_sources/scss_sources/slides_custom.scss b/slides_sources/scss_sources/slides_custom.scss
index 2d01f6d7..7691483c 100644
--- a/slides_sources/scss_sources/slides_custom.scss
+++ b/slides_sources/scss_sources/slides_custom.scss
@@ -112,6 +112,17 @@ article {
font-size: inherit;
}
}
+ .figure {
+ text-align: center;
+ a.center {
+ margin: auto;
+ text-decoration: none;
+ border: none;
+ img.center {
+ margin: auto;
+ }
+ }
+ }
dl {
margin-bottom: 10em;
dt {
diff --git a/slides_sources/source/_static/git_another_commit_on_branch.png b/slides_sources/source/_static/git_another_commit_on_branch.png
new file mode 100644
index 00000000..7ef6a068
Binary files /dev/null and b/slides_sources/source/_static/git_another_commit_on_branch.png differ
diff --git a/slides_sources/source/_static/git_checkout_branch.png b/slides_sources/source/_static/git_checkout_branch.png
new file mode 100644
index 00000000..dab12bdc
Binary files /dev/null and b/slides_sources/source/_static/git_checkout_branch.png differ
diff --git a/slides_sources/source/_static/git_checkout_master.png b/slides_sources/source/_static/git_checkout_master.png
new file mode 100644
index 00000000..dc245a7f
Binary files /dev/null and b/slides_sources/source/_static/git_checkout_master.png differ
diff --git a/slides_sources/source/_static/git_commit_on_branch.png b/slides_sources/source/_static/git_commit_on_branch.png
new file mode 100644
index 00000000..23143d7f
Binary files /dev/null and b/slides_sources/source/_static/git_commit_on_branch.png differ
diff --git a/slides_sources/source/_static/git_head.png b/slides_sources/source/_static/git_head.png
new file mode 100644
index 00000000..c48c40e6
Binary files /dev/null and b/slides_sources/source/_static/git_head.png differ
diff --git a/slides_sources/source/_static/git_master_branch.png b/slides_sources/source/_static/git_master_branch.png
new file mode 100644
index 00000000..9c4aeb8a
Binary files /dev/null and b/slides_sources/source/_static/git_master_branch.png differ
diff --git a/slides_sources/source/_static/git_merge_commit.png b/slides_sources/source/_static/git_merge_commit.png
new file mode 100644
index 00000000..2df3d2d3
Binary files /dev/null and b/slides_sources/source/_static/git_merge_commit.png differ
diff --git a/slides_sources/source/_static/git_new_branch.png b/slides_sources/source/_static/git_new_branch.png
new file mode 100644
index 00000000..a0a4ef4c
Binary files /dev/null and b/slides_sources/source/_static/git_new_branch.png differ
diff --git a/slides_sources/source/_static/git_new_commit.png b/slides_sources/source/_static/git_new_commit.png
new file mode 100644
index 00000000..012eb847
Binary files /dev/null and b/slides_sources/source/_static/git_new_commit.png differ
diff --git a/slides_sources/source/_static/git_new_commit_on_master.png b/slides_sources/source/_static/git_new_commit_on_master.png
new file mode 100644
index 00000000..6c25e51a
Binary files /dev/null and b/slides_sources/source/_static/git_new_commit_on_master.png differ
diff --git a/slides_sources/source/_static/git_simple_timeline.png b/slides_sources/source/_static/git_simple_timeline.png
new file mode 100644
index 00000000..465f546c
Binary files /dev/null and b/slides_sources/source/_static/git_simple_timeline.png differ
diff --git a/slides_sources/source/_static/remotes_clone.png b/slides_sources/source/_static/remotes_clone.png
new file mode 100644
index 00000000..8003dce2
Binary files /dev/null and b/slides_sources/source/_static/remotes_clone.png differ
diff --git a/slides_sources/source/_static/remotes_fork.png b/slides_sources/source/_static/remotes_fork.png
new file mode 100644
index 00000000..e4946961
Binary files /dev/null and b/slides_sources/source/_static/remotes_fork.png differ
diff --git a/slides_sources/source/_static/remotes_start.png b/slides_sources/source/_static/remotes_start.png
new file mode 100644
index 00000000..aa4839d0
Binary files /dev/null and b/slides_sources/source/_static/remotes_start.png differ
diff --git a/slides_sources/source/_static/remotes_upstream.png b/slides_sources/source/_static/remotes_upstream.png
new file mode 100644
index 00000000..de036593
Binary files /dev/null and b/slides_sources/source/_static/remotes_upstream.png differ
diff --git a/slides_sources/source/conf.py b/slides_sources/source/conf.py
index 10d71972..0050c14d 100644
--- a/slides_sources/source/conf.py
+++ b/slides_sources/source/conf.py
@@ -291,17 +291,9 @@
'name': u'Christopher Barker',
'email': u'PythonCHB@gmail.com',
'github': u'https://github.com/PythonCHB',
- 'company': u'UW Prof. and Continuing Education Program'
+ 'company': u'UW Professional and Continuing Education Program'
},
# {
- # 'name': u'Dan Hable',
- # 'email': u'dhable@gmail.com',
- # # 'twitter': '@crisewing',
- # # 'www': 'http://crisewing.com',
- # 'github': u'http://github.com/dhable',
- # 'company': u''
- # },
- # {
# 'name': 'Cris Ewing',
# 'twitter': '@crisewing',
# 'www': 'http://crisewing.com',
diff --git a/slides_sources/source/index.rst b/slides_sources/source/index.rst
index f26b9c4e..07ebd15a 100644
--- a/slides_sources/source/index.rst
+++ b/slides_sources/source/index.rst
@@ -23,7 +23,7 @@ In This Course
Lectures:
---------
-
+
.. toctree::
:maxdepth: 1
@@ -48,7 +48,8 @@ In This Course
.. rst-class:: credit
These materials copyright Christopher Barker and Cris Ewing, with thanks to
-Jon Jacky and Brian Dorsey for the materials from which these were derived. Licenced under the Creative Commons Attribution-ShareAlike 4.0 International Public License.
+Jon Jacky and Brian Dorsey for the materials from which these were derived.
+Licenced under the Creative Commons Attribution-ShareAlike 4.0 International Public License.
https://creativecommons.org/licenses/by-sa/4.0/legalcode
diff --git a/slides_sources/source/session01.rst b/slides_sources/source/session01.rst
index 8df6ba13..2ae3a44c 100644
--- a/slides_sources/source/session01.rst
+++ b/slides_sources/source/session01.rst
@@ -36,9 +36,8 @@ Your instructors
.. rst-class:: center large
-
-| Dan Hable
-| (dhable at gmail dot com)
+| Nathan Savage
+| (nathansavagemail at gmail dot com)
|
Who are you?
@@ -49,7 +48,7 @@ Who are you?
Tell us a tiny bit about yourself:
* name
-* programming background
+* programming background: what languages have you used?
* what do you hope to get from this class
Introduction to This Class
@@ -57,7 +56,7 @@ Introduction to This Class
.. rst-class:: center large
-Python Programming
+Intro to Python
Course Materials Online
@@ -65,25 +64,121 @@ Course Materials Online
A rendered HTML copy of the slides for this course may be found online at:
-http://codefellows.github.io/sea-f2-python-sept14/
+http://uwpce-pythoncert.github.io/IntroToPython
-Also there are homework descriptions and supplemental materials.
+Also there are some homework descriptions and supplemental materials.
-The source of these materials are in Chris' gitHub repo:
+The source of these materials are in the class gitHub repo:
-http://github.com/PythonCHB/codefellows_f2_python
+https://github.com/UWPCE-PythonCert/IntroToPython
Class email list: We will be using this list to communicate for this class:
-sea-c25@codefellows.com
+programming-in-python@googlegroups.com
+
+You should have (or will soon) received and email invitation to join
+the mailing list.
+
+
+Class Structure
+---------------
+
+Class Time:
+
+ * Some lecture, lots of demos
+ * Lab time: lots of hand-on practice
+ - Take a break if you need one then...
+ * Lather, Rinse, Repeat.....
+
+Interrupt me with questions -- please!
+
+(Some of the best learning prompted by questions)
+
+Homework:
+----------
+
+* Assigned at each class
+
+* You are adults -- it's up to you to do it
+
+* You can do a gitHub "pull request" if you want us to review it.
+
+ - We'll review how to do that later...
+
+
+Mailing list and Office Hours
+------------------------------
+
+**Mailing list:**
+
+We've set up a google group -- you will all be invited to join:
+
+``programming-in-python@googlegroups.com``
+
+**Office Hours:**
+
+I generally will hold "office hours" at a coffee shop for a couple hours
+each weekend.
+
+Nathan can do some as well.
+
+What are good times for you?
+
+
+
+Lightning Talks
+----------------
+
+**Lightning Talks:**
+
+ * 5 minutes each (including setup) - no kidding!
+ * Every student will give one
+ * Purposes: introduce yourself, share interests, also show Python applications
+ * Any topic you like, that is related to Python -- according to you!
+
-**Canvas**:
-We will be using Canvas to track your homework submission, but not much else:
+Python Ecosystem
+-----------------
+
+Python is Used for:
+
+ * CS education (this course!)
+ * Application scripting (GIS, GNU Radio, Blender...)
+ * Systems administration and "glue"
+ * Web applications (Django etc. etc. etc.)
+ * Scientific/technical computing (a la MATLAB, R, .... )
+ * Software tools (automated software testing, distributed version control, ...)
+ * Research (natural language, graph theory, distributed computing, ...)
+
+An unusually large number of niches -- versatile
+
+.. nextslide::
+
+Used by:
+
+* Beginners
+* Professional software developers, computer system administrators, ...
+* Professionals OTHER THAN computer specialists: biologists, urban planners, ....
-https://canvas.instructure.com/courses/881467
+An unusually large number of types of users -- versatile
+
+You can be productive in Python WITHOUT full-time immersion!
+
+
+Python Features
+---------------
+
+Gets many things right:
+
+* Readable -- looks nice, makes sense
+* No ideology about best way to program -- object-oriented programming, functional, etc.
+* No platform preference -- Windows, Mac, Linux, ...
+* Easy to connect to other languages -- C, Fortran - essential for science/math
+* Large standard library
+* Even larger network of external packages
+* Countless conveniences, large and small, make it pleasant to work with
-You should have received and email invitation to join the class.
What is Python?
---------------
@@ -106,7 +201,6 @@ But what does that mean?
Python Features
---------------
-Features:
.. rst-class:: build
@@ -208,7 +302,8 @@ This class uses Python 2.7 not Python 3.x
* Most code in the wild is still 2.x
* You *can* learn to write Python that is forward compatible from 2.x to 3.x
-* We will be teaching from that perspective.
+
+* We will cover that more later in the program.
* If you find yourself needing to work with Python 2 and 3, there are ways to write compatible code: https://wiki.python.org/moin/PortingPythonToPy3k
@@ -218,6 +313,8 @@ Introduction to Your Environment
There are three basic elements to your environment when working with Python:
+.. rst-class:: left
+
.. rst-class:: build
* Your Command Line
@@ -240,15 +337,6 @@ I suggest running through the **cli** tutorial at "learn code the hard way":
.. _http://cli.learncodethehardway.org/book: http://cli.learncodethehardway.org/book
-.. nextslide:: Command Line Enhancements
-
-There are a few things you can do to help make your command line a better place
-to work.
-
-Part of your homework this week will be to do these things.
-
-More on this later.
-
Your Interpreter
----------------
@@ -276,24 +364,25 @@ Try it out:
.. code-block:: pycon
- >>> print u"hello world!"
+ >>> print "hello world!"
hello world!
>>> 4 + 5
9
>>> 2 ** 8 - 1
255
- >>> print u"one string" + u" plus another"
+ >>> print "one string" + " plus another"
one string plus another
>>>
.. nextslide:: Tools in the Interpreter
-When you are in an interpreter, there are a number of tools available to you.
+When you are in an interpreter, there are a number of tools available to
+you.
There is a help system:
-.. code-block:: pycon
+.. code-block:: python
>>> help(str)
Help on class str in module __builtin__:
@@ -312,9 +401,9 @@ You can type ``q`` to exit the help viewer.
You can also use the ``dir`` builtin to find out about the attributes of a
given object:
-.. code-block:: pycon
+.. code-block:: python
- >>> bob = u"this is a string"
+ >>> bob = "this is a string"
>>> dir(bob)
['__add__', '__class__', '__contains__', '__delattr__',
'__doc__', '__eq__', '__format__', '__ge__', '__getattribute__',
@@ -380,11 +469,10 @@ In addition, great features to add include:
* Tab completion
* Code linting
* Jump-to-definition
-* Interactive follow-along for debugging
Have an editor that does all this? Feel free to use it.
-If not, I suggest ``Sublime Text``:
+If not, I suggest ``SublimeText``:
http://www.sublimetext.com/
@@ -475,6 +563,8 @@ You install it by downloading and then executing an installer script:
(or go to: http://pip.readthedocs.org/en/latest/installing.html)
+(Windows users will need to do that....)
+
.. nextslide:: Using Pip
Once you've installed pip, you use it to install Python packages by name:
@@ -484,36 +574,36 @@ Once you've installed pip, you use it to install Python packages by name:
$ pip install foobar
...
-To find packages (and their proper names), you can search the python package index (PyPI):
+To find packages (and their proper names), you can search the python
+package index (PyPI):
https://pypi.python.org/pypi
+Step 3: Install iPython
+------------------------
-Step 3: Optional -- Virtualenv
--------------------------------
-
-Python packages come in many versions.
-
-Often you need one version for one project, and a different one for another.
+As this is an intro class, we are going to use almost entirely features
+of standard library. But there are a couple things you may want:
-`Virtualenv`_ allows you to create isolated environments.
+**iPython**
-You can then install potentially conflicting software safely.
+.. code-block:: bash
-For this class, this is no big deal, but as you start to work on "real" projects, it can be a key tool.
+ $pip install ipython
-.. _Virtualenv: http://www.virtualenv.org/
+If you are using SublimeText, you may want:
-If you want to install it, here are some notes:
+.. code-block:: bash
-`Intro to VirtualEnv <./supplements/virtualenv.html>`_
+ $ pip install PdbSublimeTextSupport
Step 4: Clone Class Repository
------------------------------
-`gitHub `_ is an industry-standard system for collaboration on software projects -- particularly open source ones.
+`gitHub `_ is an industry-standard system for
+collaboration on software projects -- particularly open source ones.
We will use it this class to manage submitting and reviewing your work, etc.
@@ -521,9 +611,9 @@ We will use it this class to manage submitting and reviewing your work, etc.
Next, you'll make a copy of the class repository using ``git``.
-The canonical copy is in the CodeFellows organization on GitHub:
+The canonical copy is in the UWPCE organization on GitHub:
-https://github.com/codefellows/sea-f2-python-sept14
+https://github.com/UWPCE-PythonCert/IntroToPython
Open that URL, and click on the *Fork* button at the top right corner.
@@ -539,43 +629,20 @@ At your command line, run the following commands:
.. code-block:: bash
$ cd your_working_directory_for_the_class
- $ git clone https://github.com//sea-f2-python-sept14.git
+ $ git clone https://github.com//IntroToPython.git
(you can copy and paste that link from the gitHub page)
-If you have an SSH key set up for gitHub, you'll want to do this instead:
-
-.. code-block:: bash
-
- git@github.com:/sea-f2-python-sept14.git
-
**Remember**, should be replaced by your github account name.
-Step 5: Install Requirements
-----------------------------
-
-As this is an intro class, we are going to use almost entirely features of standand library. But there are a couple things you may want:
-
-**iPython**
-
-.. code-block:: bash
-
- $pip install ipython
-
-If you are using SublimeText, you may want:
-
-.. code-block:: bash
-
- $ pip install PdbSublimeTextSupport
-
Introduction to iPython
=======================
iPython Overview
------------------
-You have now installed `iPython`_.
+You have installed `iPython`_.
iPython is an advanced Python interpreter that offers enhancements.
@@ -597,8 +664,8 @@ Specifically, you'll want to pay attention to the information about
The very basics of iPython
--------------------------
-iPython can do a lot for you, but for starters, here are the key pieces you'll
-want to know:
+iPython can do a lot for you, but for starters, here are the key pieces
+you'll want to know:
Start it up
@@ -607,7 +674,7 @@ Start it up
$ipython
$ ipython
- Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
+ Python 2.7.6 (v2.7.6:3a1db0d2747e, Nov 10 2013, 00:42:54)
Type "copyright", "credits" or "license" for more information.
IPython 2.0.0 -- An enhanced Interactive Python.
@@ -652,7 +719,7 @@ This is the stuff I use every day:
* tab completion:
- - ``something.``
+ - ``something.``
* running a python file:
@@ -661,12 +728,13 @@ This is the stuff I use every day:
That's it -- you can get a lot done with those.
+
How to run a python file
--------------------------
A file with python code in it is a 'module' or 'script'
-(more on the distiction later on...)
+(more on the distinction later on...)
It should be named with the ``.py`` extension: ``some_name.py``
@@ -695,10 +763,55 @@ To run it, you have a couple options:
Basic Python Syntax
===================
+(Follow along in the iPython interpreter...)
+
.. rst-class:: center mlarge
-| Expressions, Statements,
+
| Values, Types, and Symbols
+|
+| Expressions and Statements
+
+
+Values
+------
+
+All of programming is really about manipulating values.
+
+.. rst-class:: build
+
+* Values are pieces of unnamed data: ``42, 'Hello, world',``
+* In Python, all values are objects
+
+ * Try ``dir(42)`` - lots going on behind the curtain!
+
+* Every value belongs to a type
+
+ * Try ``type(42)`` - the type of a value determines what it can do
+
+.. ifslides::
+
+ .. rst-class:: centered
+
+ [demo]
+
+Literals for the Basic Value types:
+------------------------------------
+
+Numbers:
+ - floating point: ``3.4``
+ - integers: ``456``
+
+Text:
+ - ``"a bit of text"``
+ - ``'a bit of text'``
+ - (either single or double quotes work -- why?)
+
+Boolean values:
+ - ``True``
+ - ``False``
+
+(There are intricacies to all of these that we'll get into later)
Code structure
@@ -729,7 +842,7 @@ Statements:
In [6]: # statements do not return a value, may contain an expression
- In [7]: print u"this"
+ In [7]: print "this"
this
In [8]: line_count = 42
@@ -743,14 +856,14 @@ It's kind of obvious, but handy when playing with code:
.. code-block:: ipython
- In [1]: print u"something"
+ In [1]: print "something"
something
-You can print multiple things:
+You can print multiple things:
.. code-block:: ipython
- In [2]: print u"the value is", 5
+ In [2]: print "the value is", 5
the value is 5
@@ -762,15 +875,13 @@ Python automatically adds a newline, which you can suppress with a comma:
.. code-block:: ipython
In [12]: for i in range(5):
- ....: print u"the value is",
+ ....: print "the value is",
....: print i
....:
the value is 0
the value is 1
the value is 2
the value is 3
- the value is 4
-
.. nextslide::
@@ -810,7 +921,7 @@ Blocks of code are delimited by a colon and indentation:
.. nextslide::
-Python uses whitespace to delineate structure.
+Python uses indentation to delineate structure.
This means that in Python, whitespace is **significant**.
@@ -861,52 +972,15 @@ But they are not:
NEVER INDENT WITH TABS
-make sure your editor is set to use spaces only --
-
-ideally even when you hit the key
+Make sure your editor is set to use spaces only --
-Values
-------
-
-.. rst-class:: build
-
-* Values are pieces of unnamed data: ``42, u'Hello, world',``
-* In Python, all values are objects
-
- * Try ``dir(42)`` - lots going on behind the curtain!
-
-* Every value belongs to a type
-
- * Try ``type(42)`` - the type of a value determines what it can do
-
-.. ifslides::
-
- .. rst-class:: centered
-
- [demo]
-
-Literals for the Basic Value types:
-------------------------------------
-
-Numbers:
- - floating point: ``3.4``
- - integers: ``456``
-
-Text:
- - ``u"a bit of text"``
- - ``u'a bit of text'``
- - (either single or double quotes work -- why?)
-
-Boolean values:
- - ``True``
- - ``False``
+Even when you hit the key
-(There are intricacies to all of these that we'll get into later)
-Values in Action
+Expressions
----------------
-An expression is made up of values and operators
+An *expression* is made up of values and operators.
.. rst-class:: build
@@ -917,12 +991,12 @@ An expression is made up of values and operators
* Integer vs. float arithmetic
* (Python 3 smooths this out)
- * Always use ``/`` when you want float results, ``//`` when you want floored (integer) results
+ * Always use ``/`` when you want float results, ``//`` when you want
+ floored (integer) results
* Type conversions
* This is the source of many errors, especially in handling text
- * Python 3 will not implicitly convert bytes to unicode
* Type errors - checked at run time only
@@ -999,10 +1073,10 @@ Evaluating the name will return the value to which it is bound
.. code-block:: ipython
- In [26]: name = u"value"
+ In [26]: name = "value"
In [27]: name
- Out[27]: u'value'
+ Out[27]: 'value'
In [28]: an_integer = 42
@@ -1014,6 +1088,24 @@ Evaluating the name will return the value to which it is bound
In [31]: a_float
Out[31]: 3.14
+Variables?
+----------
+
+.. rst-class:: build
+
+* In most languages, what I'm calling symbols, or names, are called "variables".
+
+* In fact, Ill probably call them variables in this class.
+
+* That's because they are used, for the most part, for the same purposes.
+
+* But many of you defined a "variable" as something like:
+ "a place in memory that can store values"
+
+* That is **NOT** what a name in python is!
+
+* A name can be bound to a value -- but that has nothing to do with a
+ location in memory.
In-Place Assignment
-------------------
@@ -1045,7 +1137,8 @@ also: ``-=, *=, /=, **=, \%=``
Multiple Assignment
-------------------
-You can assign multiple variables from multiple expressions in one statement
+You can assign multiple names from multiple expressions in one
+statement
.. code-block:: ipython
@@ -1068,7 +1161,7 @@ Python evaluates all the expressions on the right before doing any assignments
Nifty Python Trick
------------------
-Using this feature, we can swap values between two symbols in one statement:
+Using this feature, we can swap values between two names in one statement:
.. code-block:: ipython
@@ -1094,7 +1187,7 @@ Deleting
You can't actually delete anything in python...
-``del`` only unbinds a name.
+``del`` only deletes a name (or unbinds the name...)
.. code-block:: ipython
@@ -1200,7 +1293,7 @@ You can test for the equality of certain values with the ``==`` operator
In [79]: val1 == val2
Out[79]: True
- In [80]: val3 = u'50'
+ In [80]: val3 = '50'
In [81]: val1 == val3
Out[84]: False
@@ -1230,7 +1323,7 @@ Python Operator Precedence
Parentheses and Literals:
``(), [], {}``
- ``"", b'', u''``
+ ``"", b'', ''``
Function Calls:
``f(args)``
@@ -1282,36 +1375,37 @@ Anonymous Functions:
String Literals
---------------
-You define a ``string`` value by writing a *literal*:
+A "string" is a chunk of text.
+
+You define a ``string`` value by writing a string *literal*:
.. code-block:: ipython
- In [1]: u'a string'
- Out[1]: u'a string'
+ In [1]: 'a string'
+ Out[1]: 'a string'
- In [2]: u"also a string"
- Out[2]: u'also a string'
+ In [2]: "also a string"
+ Out[2]: 'also a string'
- In [3]: u"a string with an apostrophe: isn't it cool?"
- Out[3]: u"a string with an apostrophe: isn't it cool?"
+ In [3]: "a string with an apostrophe: isn't it cool?"
+ Out[3]: "a string with an apostrophe: isn't it cool?"
- In [4]: u'a string with an embedded "quote"'
- Out[4]: u'a string with an embedded "quote"'
+ In [4]: 'a string with an embedded "quote"'
+ Out[4]: 'a string with an embedded "quote"'
-(what's the '``u``' about?)
.. nextslide::
.. code-block:: ipython
- In [5]: u"""a multi-line
+ In [5]: """a multi-line
...: string
...: all in one
...: """
- Out[5]: u'a multi-line\nstring\nall in one\n'
+ Out[5]: 'a multi-line\nstring\nall in one\n'
- In [6]: u"a string with an \n escaped character"
- Out[6]: u'a string with an \n escaped character'
+ In [6]: "a string with an \n escaped character"
+ Out[6]: 'a string with an \n escaped character'
In [7]: r'a "raw" string, the \n comes through as a \n'
Out[7]: 'a "raw" string, the \\n comes through as a \\n'
@@ -1343,19 +1437,19 @@ If you try to use any of the keywords as symbols, you will cause a
.. code-block:: ipython
- In [13]: del = u"this will raise an error"
+ In [13]: del = "this will raise an error"
File "", line 1
- del = u"this will raise an error"
+ del = "this will raise an error"
^
SyntaxError: invalid syntax
.. code-block:: ipython
- In [14]: def a_function(else=u'something'):
+ In [14]: def a_function(else='something'):
....: print else
....:
File "", line 1
- def a_function(else=u'something'):
+ def a_function(else='something'):
^
SyntaxError: invalid syntax
@@ -1388,18 +1482,18 @@ You are free to rebind these symbols:
.. code-block:: ipython
- In [15]: type(u'a new and exciting string')
- Out[15]: unicode
+ In [15]: type('a new and exciting string')
+ Out[15]: str
- In [16]: type = u'a slightly different string'
+ In [16]: type = 'a slightly different string'
- In [17]: type(u'type is no longer what it was')
+ In [17]: type('type is no longer what it was')
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
- ----> 1 type(u'type is no longer what it was')
+ ----> 1 type('type is no longer what it was')
- TypeError: 'unicode' object is not callable
+ TypeError: 'str' object is not callable
In general, this is a **BAD IDEA**.
@@ -1473,7 +1567,7 @@ Functions: ``def``
.. rst-class:: build
* it is executed
- * it creates a local variable
+ * it creates a local name
.. nextslide::
@@ -1493,7 +1587,7 @@ function defs must be executed before the functions can be called:
.. code-block:: ipython
In [18]: def simple():
- ....: print u"I am a simple function"
+ ....: print "I am a simple function"
....:
In [19]: simple()
@@ -1524,7 +1618,7 @@ back is
.. code-block:: ipython
In [5]: def exceptional():
- ...: print u"I am exceptional!"
+ ...: print "I am exceptional!"
...: print 1/0
...:
In [6]: def passive():
@@ -1558,7 +1652,7 @@ Functions: Tracebacks
in exceptional()
1 def exceptional():
- 2 print u"I am exceptional!"
+ 2 print "I am exceptional!"
----> 3 print 1/0
4
@@ -1608,12 +1702,12 @@ This is useful when debugging!
.. code-block:: ipython
In [14]: def no_error():
- ....: return u'done'
+ ....: return 'done'
....: # no more will happen
....: print 1/0
....:
In [15]: no_error()
- Out[15]: u'done'
+ Out[15]: 'done'
.. nextslide::
@@ -1684,11 +1778,11 @@ In order to do anything interesting at all (including this week's homework), you
In [12]: def test(a):
....: if a == 5:
- ....: print u"that's the value I'm looking for!"
+ ....: print "that's the value I'm looking for!"
....: elif a == 7:
- ....: print u"that's an OK number"
+ ....: print "that's an OK number"
....: else:
- ....: print u"that number won't do!"
+ ....: print "that number won't do!"
In [13]: test(5)
that's the value I'm looking for!
@@ -1710,48 +1804,24 @@ That's it for our basic intro to Python
Before next session, you'll use what you've learned here today to do some
exercises in Python programming
+Schedule the lightning talks:
+-----------------------------
-Homework
-========
-
-Four Tasks by Next Monday
-
-
-Task 1
-------
-
-**Tell Us About Yourself**
-
-This is a way for you to learn a bit about gitHub, and how you are going to submit most of your homework.
-
-* Create a new folder in the ``students`` folder in the class repository.
-
- * Create the folder in your clone of your fork of the repository.
- * Name it with your own name in CamelCase, like: ``ChrisBarker``.
- * In the folder create one new file, named ``README.md``
- * In that new file, write up a few paragraphs about yourself.
+.. rst-class:: build
- * Use proper `markdown`_ syntax. (or `reStructuredText`_)
- * Include at least two headings, of different levels.
- * Include at least one link.
+* We need to schedule your lightning talks.
-.. _markdown: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
+* **Let's use Python for that !**
-.. _reStructuredText: http://docutils.sourceforge.net/rst.html
+[demo]
-.. nextslide::
+Homework
+========
-* Using ``git add``, add the new folder and file to your clone of the
- repository.
-* Using ``git commit``, commit your changes to your clone (write a good commit
- message). If you later edit your file, don't forget to commit those changes
- too.
-* Using ``git push``, push your commits to your fork on GitHub.
-* In GitHub's Web UI, make a ``pull request`` to the original CodeFellows
- repository.
+??? Tasks by Next Week
-Task 2
+Task 1
------
**Set Up a Great Dev Environment**
@@ -1761,7 +1831,10 @@ Make sure you have the basics of command line usage down:
Work through the supplemental tutorials on setting up your
`Command Line`_ for good development support.
-Make sure you've got your editor set up productively -- at the very very least, make sure it does Python indentation well.
+Make sure you've got your editor set up productively -- at the very very
+least, make sure it does Python indentation and syntax coloring well.
+
+.. nextslide::
**Advanced Editor Setup:**
@@ -1780,7 +1853,9 @@ editor.
.. _SublimeText: supplements/sublime_as_ide.html
.. _Command Line: supplements/shell.html
-Task 3
+Also make sure you've got iPython working, if you didn't get to that in class.
+
+Task 2
------
**Python Pushups**
@@ -1788,67 +1863,153 @@ Task 3
To get a bit of exercise solving some puzzles with Python, work on the Python
exercises at `CodingBat`_.
-Begin by making an account on the site. Once you have done so, go to the
-'prefs' link at the top right and enter your name so we know who you are.
-
-In addition, add the following email address to the 'Share To' box. This will
-allow your instructors to see the work you have done.
-
-::
-
- pyinstructor@codefellows.com
-There are 8 sets of puzzles. Do as many as you can, starting with the Warmups.
+There are 8 sets of puzzles. Do as many as you can, but try to at least
+get all the "Warmups" done.
.. _CodingBat: http://codingbat.com
-**Please Note:** Do Not send emails to the above email address, they will not
-be answered.
-
-Task 4
+Task 3
------
**Explore Errors**
-* Create a new directory in your personal folder in the ``students`` folder of the class repository::
-
+* Create a new directory in your working dir for the class::
+
$ mkdir session01
$ cd session01
-* Make sure you create it in your clone of your fork of the repository.
* Add a new file to it called ``break_me.py``
-* Use ``git add`` to add the file to the repository.
-
-.. nextslide::
* In the ``break_me.py`` file write four simple Python functions:
* Each function, when called, should cause an exception to happen
+
* Each function should result in one of the four common exceptions from our
lecture.
- * for review: ``NameError``, ``TypeError``, ``SyntaxError``, ``AttributeError``
+ * for review: ``NameError``, ``TypeError``, ``SyntaxError``, ``AttributeError``
(hint -- the interpreter will quit when it hits a Exception -- so you can comment out all but the one you are testing at the moment)
* Use the Python standard library reference on `Built In Exceptions`_ as a
reference
+.. _Built In Exceptions: https://docs.python.org/2/library/exceptions.html
+
+Task 5
+-------
+
+**Part 1** (adapted from Downey, "Think Python", ex. 3.5)
+
+Write a function that draws a grid like the following::
+
+ + - - - - + - - - - +
+ | | |
+ | | |
+ | | |
+ | | |
+ + - - - - + - - - - +
+ | | |
+ | | |
+ | | |
+ | | |
+ + - - - - + - - - - +
+
.. nextslide::
-* Use ``git commit`` to commit changes you make to your clone
+Hint: to print more than one value on a line, you can print a comma-separated sequence:
+``print '+', '-'``
- * Make frequent, small commits using ``git commit`` when working.
- * Write clear, concise commit messages that explain what you are doing.
+If the sequence ends with a comma, Python leaves the line unfinished, so the value printed next appears on the same line.
-* When you are finished with your work, use ``git push`` to push your changes
- to your fork on GitHub.
+::
-* Finally, issue a pull request to the original CodeFellows repository with
- your work.
+ print '+',
+ print '-'
+
+The output of these statements is ``'+ -'``.
+
+A print statement all by itself ends the current line and goes to the next line.
+
+.. nextslide::
+
+**Part 2:**
+
+Write a function ``print_grid()`` that takes one integer argument
+and prints a grid like the picture above, BUT the size of the
+grid is given by the argument.
+
+For example, ``print_grid(11)`` prints the grid in the above picture.
+
+This problem is underspecified. Do something reasonable.
+
+Hints:
+
+ A character is a string of length 1
+
+ ``s + t`` is string ``s`` followed by string ``t``
+
+ ``s * n`` is string ``s`` replicated n times
+
+.. nextslide::
+
+**Part 3:**
+
+Write a function that draws a similar grid with three rows and three columns.
+
+(what to do about rounding?)
+
+And while you are at it -- n rows and columns...
+
+
+Recommended Reading, etc.
+-------------------------
+
+If you want some more practice with these key concepts:
+
+*Think Python:* Chapters 1–7 (http://greenteapress.com/thinkpython/)
+
+*Dive Into Python:* Chapters 1–3 (http://www.diveinto.org/python3/)
+
+*LPTHW:* ex. 1–10, 18-21 (http://learnpythonthehardway.org/book/)
+
+Or follow this Excellent introductory tutorial:
+
+http://pyvideo.org/video/1850/a-hands-on-introduction-to-python-for-beginning-p
+
+
+Next Class
+===========
+
+.. rst-class:: left
+
+Next class I will be out of town.
+
+.. rst-class:: left
+
+You will be in the capable hands of Cris Ewing
+
+.. rst-class:: left
+
+Cris is the instructor for the next class in this sequence
+
+.. rst-class:: left
+
+And a great teacher.
+
+Office Hours
+------------
+
+I'll do office hours on either Saturday or Sunday from 12:00 -- 3:00
+
+Probably in Wallingford, or maybe South Lake Union
+
+Do you have a preference?
+
+Nathan's office hours??
-.. _Built In Exceptions: https://docs.python.org/2/library/exceptions.html
diff --git a/slides_sources/source/session02.rst b/slides_sources/source/session02.rst
index b51b55c5..28fcc375 100644
--- a/slides_sources/source/session02.rst
+++ b/slides_sources/source/session02.rst
@@ -29,67 +29,336 @@ Homework Review
Any questions that are nagging?
+Class Outline
+=============
-Git Work
-========
+.. rst-class:: left
+
+ * git primer
+ * Some basic Python
+ * More on Functions
+ * Boolean Expressions
+ * Code Structure, Modules, and Namespaces
+
+
+First a little git Primer...
+==============================
.. rst-class:: center large
-Let's get to know your fellow students!
+Let's get to know git a bit
+
+
+What is git?
+------------
+
+.. rst-class:: build
+
+.. container::
+
+ A "version control system"
+
+ A history of everything you do to your code
+
+ A graph of "states" in which your code has existed
+
+ That last one is a bit tricky, so let's talk it over for a minute
+
+A Picture of git
+----------------
+
+.. figure:: /_static/git_simple_timeline.png
+ :width: 80%
+ :class: center
+
+.. rst-class:: build
+.. container::
+
+ A git repository is a set of points in time, with history showing where
+ you've been.
+
+ Each point has a *name* (here *A*, *B*, *C*) that uniquely identifies it,
+ called a *hash*
+
+ The path from one point to the previous is represented by the *difference*
+ between the two points.
+.. nextslide::
+
+.. figure:: /_static/git_head.png
+ :width: 75%
+ :class: center
+
+.. rst-class:: build
+.. container::
-Working with an Upstream
-------------------------
+ Each point in time can also have a label that points to it.
-You've created a fork of the class repository from the ``codefellows`` account
-on GitHub.
+ One of these is *HEAD*, which always points to the place in the timeline
+ that you are currently looking at.
-You've pushed your own changes to that fork, and then issued pull requests to
-have that worked merged back to the ``codefellows`` original.
+.. nextslide::
-You want to keep your fork up-to-date with that original copy as the class goes
-forward.
+.. figure:: /_static/git_master_branch.png
+ :width: 75%
+ :class: center
-To do this, you use the git concept of an **upstream** repository.
+.. rst-class:: build
+.. container::
+
+ You may also be familiar with the label "master".
+
+ This is the name that git automatically gives to the first *branch* in a
+ repository.
+
+ A *branch* is actually just a label that points to a specific point in
+ time.
.. nextslide::
+.. figure:: /_static/git_new_commit.png
+ :width: 75%
+ :class: center
+
+.. rst-class:: build
+.. container::
+
+ When you make a *commit* in git, you add a new point to the timeline.
+
+ The HEAD label moves to this new point.
+
+ So does the label for the *branch* you are on.
+
+.. nextslide:: Making a Branch
+
+.. figure:: /_static/git_new_branch.png
+ :width: 75%
+ :class: center
+
+.. rst-class:: build
+.. container::
+
+ You can make a new *branch* with the ``branch`` command.
+
+ This adds a new label to the current commit.
+
+ Notice that it *does not* check out that branch.
+
+.. nextslide:: Making a Branch
+
+.. figure:: /_static/git_checkout_branch.png
+ :width: 75%
+ :class: center
+
+.. rst-class:: build
+.. container::
+
+ You can use the ``checkout`` command to switch to the new branch.
+
+ This associates the HEAD label with the *session01* label.
+
+ Use ``git branch`` to see which branch is *active*::
+
+ $ git branch
+ master
+ * session01
+
+.. nextslide:: Making a Branch
+
+.. figure:: /_static/git_commit_on_branch.png
+ :width: 75%
+ :class: center
+
+.. rst-class:: build
+.. container::
+
+ While it is checked out, new commits move the *session01* label.
+
+ Notice that HEAD is *always* the same as "where you are now"
+
+.. nextslide:: Making a Branch
+
+You can use this to switch between branches and make changes in isolation.
+
+.. rst-class:: build
+.. container::
+
+ .. figure:: /_static/git_checkout_master.png
+ :width: 75%
+ :class: center
+
+ .. figure:: /_static/git_new_commit_on_master.png
+ :width: 75%
+ :class: center
+
+.. nextslide:: Merging Branches
+
+.. rst-class:: build
+.. container::
+
+ Branching allows you to keep related sets of work separate from each-other.
+
+ In class here, you can use it to do your homework for each session.
+
+ Simply create a new branch for each session from your repository master
+ branch.
+
+ Do your work on that branch, and then you can issue a **pull request** in
+ github to have your work evaluated.
+
+ This is very much like how teams work in the "real world" so learning it
+ here will help you.
+
+ The final step in the process is merging your work.
+
+.. nextslide:: Merging Branches
+
+The ``merge`` command allows you to *combine* your work on one branch with the
+work on another.
+
+.. rst-class:: build
+.. container::
+
+ It creates a new commit which reconciles the differences:
+
+ .. figure:: /_static/git_merge_commit.png
+ :width: 75%
+ :class: center
+
+ Notice that this commit has **two** parents.
+
+
+.. nextslide:: Conflicts
+
+.. rst-class:: build
+.. container::
+
+ Sometimes when you ``merge`` two branches, you get *conflicts*.
+
+ This happens when the same file was changed in about the same place in two
+ different ways.
+
+ Often, git can work these types of things out on its own, but if not,
+ you'll need to manually edit files to fix the problem.
+
+ You'll be helped by the fact that git will tell you which files are in
+ conflict.
+
+ Just open those files and look for conflict markers:
+
+ * <<<<<<<<< *hash1* (stuff from the current branch)
+ * ========= (the pivot point between two branches' content)
+ * >>>>>>>>> *hash2* (stuff from the branch being merged)
+
+.. nextslide:: Conflicts
+
+Your job in fixing a conflict is to decide exactly what to keep.
+
+You can (and should) communicate with others on your team when doing this.
+
+Always remember to remove the conflict markers too. They are not syntactic
+code in any language and will cause errors.
+
+Once a conflict is resolved, you can ``git add`` the file back and then commit
+the merge.
+
+
+Working with Remotes
+--------------------
+
Since ``git`` is a *distributed* versioning system, there is no **central**
repository that serves as the one to rule them all.
-Instead, you work with *local* repositories, and *remotes* that they are
-connected to.
+.. rst-class:: build
+.. container::
+
+ Instead, you work with *local* repositories, and *remotes* that they are
+ connected to.
-Cloned repositories get an *origin* remote for free:
+ Cloned repositories get an *origin* remote for free:
-.. code-block:: bash
+ .. code-block:: bash
+
+ $ git remote -v
+ origin https://github.com/PythonCHB/sea-f2-python-sept14.git (fetch)
+ origin https://github.com/PythonCHB/sea-f2-python-sept14.git (push)
+
+ This shows that the local repo on my machine *originated* from the one in
+ my gitHub account (the one it was cloned from)
+
+.. nextslide::
+
+Our class materials reside in a repository on *Github* in the
+*UWPCE-PythonCert* organization:
+
+.. figure:: /_static/remotes_start.png
+ :width: 50%
+ :class: center
+
+.. nextslide::
+
+You've created a fork of the class repository from the ``UWPCE-PythonCert``
+account on GitHub into your personal account:
- $ git remote -v
- origin https://github.com/PythonCHB/sea-f2-python-sept14.git (fetch)
- origin https://github.com/PythonCHB/sea-f2-python-sept14.git (push)
+.. figure:: /_static/remotes_fork.png
+ :width: 50%
+ :class: center
-This shows that the local repo on my machine *originated* from the one in my gitHub account (the one it was cloned from)
+.. nextslide::
+
+You've made a *clone* of your fork to your own computer, which means that
+**your fork** in github is the *origin*:
+
+.. figure:: /_static/remotes_clone.png
+ :width: 50%
+ :class: center
+
+.. nextslide::
+
+.. rst-class:: build
+.. container::
+
+ You've pushed your own changes to that fork, and then issued pull requests
+ to have that worked merged back to the ``UWPCE-PythonCert`` original.
+
+ You want to keep your fork up-to-date with that original copy as the class
+ goes forward.
+
+ To do this, you add a new *remote* repository to your local clone.
.. nextslide:: Adding a Remote
You can add *remotes* at will, to connect your *local* repository to other
copies of it in different remote locations.
-This allows you to grab changes made to the repository in these other
-locations.
+.. rst-class:: build
+.. container::
+
+ This allows you to grab changes made to the repository in these other
+ locations.
-For our class, we will add an *upstream* remote to our local copy that points
-to the original copy of the material in the ``codefellows`` account.
+ For our class, we will add an *upstream* remote to our local copy that points
+ to the original copy of the material in the ``UWPCE-PythonCert`` account.
-.. code-block:: bash
+ .. code-block:: bash
+
+ $ git remote add upstream https://github.com/UWPCE-PythonCert/IntroToPython.git
- $ git remote add upstream https://github.com/codefellows/sea-f2-python-sept14.git
+ $ git remote -v
+ origin https://github.com/PythonCHB/sea-f2-python-sept14.git (fetch)
+ origin https://github.com/PythonCHB/sea-f2-python-sept14.git (push)
+ upstream https://github.com/UWPCE-PythonCert/IntroToPython.git (fetch)
+ upstream https://github.com/UWPCE-PythonCert/IntroToPython.git (push)
+
+
+.. nextslide::
+
+This should leave you in a situation that looks like this:
+
+.. figure:: /_static/remotes_upstream.png
+ :width: 50%
+ :class: center
- $ git remote -v
- origin https://github.com/PythonCHB/sea-f2-python-sept14.git (fetch)
- origin https://github.com/PythonCHB/sea-f2-python-sept14.git (push)
- upstream https://github.com/codefellows/sea-f2-python-sept14.git (fetch)
- upstream https://github.com/codefellows/sea-f2-python-sept14.git (push)
.. nextslide:: Fetching Everything.
@@ -136,7 +405,7 @@ Then, fetch the upstream master branch and merge it into your master:
.. code-block:: bash
$ git fetch upstream master
- From https://github.com/codefellows/sea-f2-python-sept14
+ From https://github.com/UWPCE-PythonCert/IntroToPython
* branch master -> FETCH_HEAD
$ git merge upstream/master
@@ -185,6 +454,7 @@ You can incorporate this into your daily workflow: ::
$ git push
[make a pull request]
+
Quick Intro to Basics
=====================
@@ -334,6 +604,18 @@ Each of these have intricacies special to python
We'll get to those over the next couple of classes
+BREAK TIME
+==========
+
+Take a few moments to take a breather, when we return we'll do two lightning
+talks:
+
+.. ifslides::
+
+ * Chantal Huynh
+ * David Fugelso
+
+
Functions
=========
@@ -430,14 +712,12 @@ Try it and see:
UnboundLocalError Traceback (most recent call last)
in ()
----> 1 f()
-
in f()
1 def f():
----> 2 y = x
3 x = 5
4 print x
5 print y
-
UnboundLocalError: local variable 'x' referenced before assignment
Because you are binding the symbol ``x`` locally, it becomes a local and masks
@@ -511,29 +791,6 @@ provide any *positional* arguments:
fun(x=5, 6)
SyntaxError: non-keyword arg after keyword arg
-.. nextslide:: Parameters and Unpacking
-
-This brings us to a fun feature of Python function definitions.
-
-You can define a parameter list that requires an **unspecified** number of
-*positional* or *keyword* arguments.
-
-The key is the ``*`` (splat) or ``**`` (double-splat) operator:
-
-.. code-block:: ipython
-
- In [31]: def fun(*args, **kwargs):
- ....: print args, kwargs
- ....:
- In [32]: fun(1)
- (1,) {}
- In [33]: fun(1, 2, zombies="brains")
- (1, 2) {'zombies': 'brains'}
- In [34]: fun(1, 2, 3, zombies="brains", vampires="blood")
- (1, 2, 3) {'vampires': 'blood', 'zombies': 'brains'}
-
-**args** and **kwargs** are *conventional* names for these.
-
Documentation
-------------
@@ -674,27 +931,6 @@ We can use a recursive function nicely to model this mathematical function
[demo]
-In-Class Lab:
-=============
-
-.. rst-class:: center large
-
-Fun With Functions
-
-Exercises
----------
-
-Try your hand at writing a function that computes the distance between two
-points::
-
- dist = sqrt( (x1-x2)**2 + (y1-y2)**2 )
-
-Experiment with ``locals`` by adding this statement to the function you just
-wrote:::
-
- print locals()
-
-
Boolean Expressions
===================
@@ -723,8 +959,8 @@ Determining Truthiness:
.. rst-class:: build
-* ``None``
-* ``False``
+* ``None``
+* ``False``
* **Nothing:**
* zero of any numeric type: ``0, 0L, 0.0, 0j``.
@@ -816,12 +1052,12 @@ statements:
else return x
if x is false,
- x and y return x
- else return y
+ x and y return x
+ else return y
if x is false,
- not x return True,
- else return False
+ not x return True,
+ else return False
.. nextslide:: Chaining
@@ -930,24 +1166,44 @@ In-Class Lab:
.. rst-class:: center large
-Better With Booleans
+Funky Bools
Exercises
---------
- * Look up the ``%`` operator. What do these do?
+* Try your hand at writing a function that computes the distance between two
+ points::
+
+ dist = sqrt( (x1-x2)**2 + (y1-y2)**2 )
+
+ print locals()
- * ``10 % 7 == 3``
- * ``14 % 7 == 0``
- * Write a program that prints the numbers from 1 to 100 inclusive. But for
- multiples of three print "Fizz" instead of the number and for the
- multiples of five print "Buzz". For numbers which are multiples of both
- three and five print "FizzBuzz" instead.
- * Re-write a couple of CodingBat exercises, using a conditional expression
- * Re-write a couple of CodingBat exercises, returning the direct boolean results
+* Look up the ``%`` operator. What do these do?
+
+ * ``10 % 7 == 3``
+ * ``14 % 7 == 0``
+
+* Write a program that prints the numbers from 1 to 100 inclusive. But for
+ multiples of three print "Fizz" instead of the number and for the multiples
+ of five print "Buzz". For numbers which are multiples of both three and five
+ print "FizzBuzz" instead.
+
+* Experiment with ``locals`` by adding this statement to the functions you just
+ wrote:::
+
+ print locals()
+
+
+BREAK TIME
+==========
+
+Again, let's take a few moments out to take a short break. When we return
+we'll have our second two lightning talks:
+
+.. ifslides::
-use whichever you like, or the ones in:
-:download:`codingbat.rst <../code/session02/codingbat.rst>`
+ * Ian M Davis
+ * Schuyler Alan Schwafel
Code Structure, Modules, and Namespaces
@@ -1174,7 +1430,7 @@ module*
This is useful in a number of cases.
-You can put code here that lets your module be a utility script
+You can put code here that lets your module be a utility *script*
You can put code here that demonstrates the functions contained in your module
diff --git a/slides_sources/source/supplements/python_for_mac.rst b/slides_sources/source/supplements/python_for_mac.rst
index a3d5541e..205ab54b 100644
--- a/slides_sources/source/supplements/python_for_mac.rst
+++ b/slides_sources/source/supplements/python_for_mac.rst
@@ -6,16 +6,25 @@ Setting up your Mac for Python and this class
Getting The Tools
==================
+.. rst-class:: left
+
OS-X comes with Python out of the box, but not the full setup you'll need for development, and this class.
+.. rst-class:: left
+
**Note**:
+.. rst-class:: left
+
If you use ``macports`` or ``homebrew`` to manage \*nix software on your machine, feel free to use those for ``python``, ``git``, etc, as well. If not, then read on.
Python
-------
-While OS-X does provide python our of the box -- it tends not to have the latest version, and you really don't want to mess with the system installation. So I recommend installing an independent installation from ``python.org``:
+While OS-X does provide python out of the box -- it tends not to have the
+latest version, and you really don't want to mess with the system
+installation. So I recommend installing an independent installation from
+``python.org``:
Download and install Python 2.7.8 from Python.org:
@@ -23,6 +32,7 @@ https://www.python.org/ftp/python/2.7.8/python-2.7.8-macosx10.6.dmg
Simple as that.
+
Terminal
---------
diff --git a/slides_sources/source/supplements/python_for_windows.rst b/slides_sources/source/supplements/python_for_windows.rst
index fccdfbed..fd54c209 100644
--- a/slides_sources/source/supplements/python_for_windows.rst
+++ b/slides_sources/source/supplements/python_for_windows.rst
@@ -51,7 +51,7 @@ git
Get a git client -- the gitHub GUI client may be nice -- I honestly don't know.
-There is also ToroiseGit:
+There is also TortoiseGit:
https://code.google.com/p/tortoisegit/