Skip to content

Commit 06fa671

Browse files
committed
final? presentations
1 parent c90bbea commit 06fa671

2 files changed

Lines changed: 127 additions & 41 deletions

File tree

week-04/presentation-week04.tex

Lines changed: 125 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,15 @@ \section{Review/Questions}
3030
\begin{frame}{Review of Previous Class}
3131

3232
\begin{itemize}
33-
\item ...
33+
\item String formatting
34+
\item File reading and writing
35+
\item Unicode
36+
\item Exception Handling
37+
\item Path and Directories
3438
\end{itemize}
3539

40+
\vfill
41+
{\Large Questions?}
3642
\end{frame}
3743

3844

@@ -44,6 +50,68 @@ \section{Review/Questions}
4450

4551
\end{frame}
4652

53+
% ---------------------------------------------
54+
\begin{frame}[fragile]{CodingBat}
55+
56+
{\Large List-1 -- sum2}
57+
58+
\begin{verbatim}
59+
def sum2(nums):
60+
if ( len( nums ) > 1 ):
61+
return nums[0] + nums[1]
62+
elif ( nums ):
63+
return nums[0]
64+
return 0
65+
\end{verbatim}
66+
67+
{\Large \verb|sum()| is handy: }
68+
69+
\begin{verbatim}
70+
def sum2(nums):
71+
return sum(nums[:2])
72+
\end{verbatim}
73+
74+
75+
\end{frame}
76+
77+
% ---------------------------------------------
78+
\begin{frame}[fragile]{CodingBat}
79+
80+
{\Large \verb| String-1 -- make_tags|}
81+
82+
\begin{verbatim}
83+
def make_tags(tag, word):
84+
return "<" + tag + ">" + word + "</" + tag + ">"
85+
\end{verbatim}
86+
87+
{\Large string formatting...}
88+
89+
\begin{verbatim}
90+
def make_tags(tag, word):
91+
return "<%s>%s</%s>"%(tag,word,tag)
92+
\end{verbatim}
93+
94+
\begin{verbatim}
95+
def make_tags(tag, word):
96+
return "<%(tag)s>%(word)s</%(tag)s>"% \
97+
{'tag':tag, 'word':word}
98+
\end{verbatim}
99+
100+
\end{frame}
101+
102+
%-------------------------------
103+
\begin{frame}{Lightning Talk}
104+
105+
{\center
106+
107+
\LARGE Lighting Talk:
108+
\vfill
109+
Joshua
110+
\vfill
111+
112+
}
113+
\end{frame}
114+
47115
\section{More on function calling}
48116

49117
% ---------------------------------------------
@@ -140,10 +208,6 @@ \section{More on function calling}
140208
In [158]: fun()
141209
x is: 4
142210
143-
In [159]: y = 6
144-
145-
In [160]: fun()
146-
x is: 4
147211
\end{verbatim}
148212

149213
\end{frame}
@@ -175,18 +239,18 @@ \section{More on function calling}
175239
\begin{frame}[fragile]{Keyword arguments}
176240

177241
\begin{verbatim}
178-
In [161]: l = []
179-
In [162]: for i in range(3):
180-
.....: def fun(x=i):
181-
.....: print x
182-
.....: l.append(fun)
183-
In [163]: l
184-
Out[163]: [<function __main__.fun>, <function __main__.fun>, <function __main__.fun>]
185-
In [164]: l[0]
186-
Out[164]: <function __main__.fun>
187-
In [165]: l[0]()
242+
>>> l = []
243+
>>> for i in range(3):
244+
>>> def fun(x=i):
245+
>>> print x
246+
>>> l.append(fun)
247+
>>> l
248+
[<function __main__.fun>, <function __main__.fun>, <function __main__.fun>]
249+
>>> l[0]
250+
<function __main__.fun>
251+
>>> l[0]()
188252
0
189-
In [166]: l[1]()
253+
>>> l[1]()
190254
1
191255
\end{verbatim}
192256

@@ -232,29 +296,35 @@ \section{More on function calling}
232296
%-------------------------------
233297
\begin{frame}{LAB}
234298

299+
{\Large keyword arguments}
235300
\begin{itemize}
236-
\item keyword arguments
301+
\item Write a function that has four optional parameters\\
302+
(with defaults):
303+
\begin{itemize}
304+
\item foreground\_color
305+
\item background\_color
306+
\item link\_color
307+
\item visited\_link\_color
308+
\end{itemize}
309+
\item Have it print the colors.
310+
\item Call it with a couple different parameters set
237311
\end{itemize}
238312

239313
\end{frame}
240314

241-
242315
%-------------------------------
243316
\begin{frame}{Lightning Talk}
244317

245318
{\center
246319

247320
\LARGE Lighting Talk:
248321
\vfill
249-
Joshua
322+
David
250323
\vfill
251324

252325
}
253326
\end{frame}
254327

255-
256-
257-
258328
\section{Lists, Tuples...}
259329

260330
% ---------------------------------------------
@@ -960,18 +1030,21 @@ \section{Lists, Tuples...}
9601030

9611031
\end{frame}
9621032

963-
%-------------------------------
1033+
%%-------------------------------
9641034
\begin{frame}{Lightning Talk}
9651035

9661036
{\center
9671037

9681038
\LARGE Lighting Talk:
1039+
9691040
\vfill
970-
David
1041+
Rob
9711042
\vfill
9721043

9731044
}
974-
\end{frame}
1045+
1046+
\end{frame}
1047+
%
9751048

9761049
% ##################################
9771050
\section{Dictionaries and Sets}
@@ -1270,6 +1343,21 @@ \section{Dictionaries and Sets}
12701343
(not as useful with the dict() constructor...)
12711344
\end{frame}
12721345

1346+
% ----------------------------------------------
1347+
\begin{frame}[fragile]{Switch ?}
1348+
1349+
{\Large How do you spell switch/case in Python?}
1350+
1351+
\vfill
1352+
{\Large Put the values to switch on in the keys:}
1353+
1354+
\vfill
1355+
{\Large Functions to call in values:}
1356+
1357+
\vfill
1358+
demo: sample code (\verb|switch_case.py|)
1359+
\end{frame}
1360+
12731361

12741362
% ---------------------------------------------
12751363
\begin{frame}[fragile]{ Sets }
@@ -1430,10 +1518,6 @@ \section{Dictionaries and Sets}
14301518

14311519
\end{frame}
14321520

1433-
1434-
1435-
1436-
14371521
%-------------------------------
14381522
\begin{frame}{LAB}
14391523

@@ -1455,15 +1539,17 @@ \section{Dictionaries and Sets}
14551539

14561540
\end{frame}
14571541

1458-
%%-------------------------------
1459-
%\begin{frame}{Lightning Talk}
1460-
%
1461-
%{\center
1462-
%
1463-
%\LARGE Lighting Talk:
1464-
%\vfill
1465-
%Rob
1466-
%\vfill
1467-
%
1542+
%-------------------------------
1543+
\begin{frame}{Homework}
1544+
1545+
\begin{itemize}
1546+
\item Spend more time (or some time) with the Coding Kata from lab. Get it basically working.
1547+
\item Experiment with different lengths for the lookup key. (3 words, 4 words, 3 letters, etc)
1548+
\item This assignment is about playing around with the algorithm and data.
1549+
\end{itemize}
1550+
1551+
\end{frame}
1552+
1553+
14681554

14691555
\end{document}

week-05/code/socket_serve1.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
serversocket = socket.socket( socket.AF_INET, socket.SOCK_STREAM)
1515

1616
#bind the socket to localhost, high port
17-
serversocket.bind(('localhost', 55559),)
17+
serversocket.bind(('localhost', 55555),)
1818
#become a server socket
1919
serversocket.listen(5)
2020

@@ -37,4 +37,4 @@
3737
clientsocket.send("This is some text")
3838

3939
## put this in your browser while this is running:
40-
## http://localhost:55557/a_file
40+
## http://localhost:55555/a_file

0 commit comments

Comments
 (0)