Skip to content

Commit b02ebd1

Browse files
committed
Merge pull request #1 from UWPCE-PythonCert/master
update from original
2 parents 5bb813b + 7e5a655 commit b02ebd1

176 files changed

Lines changed: 7481 additions & 493 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
slides_sources/build

Examples/Session01/schedule.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
week 2: Chantal Huynh
2+
week 2: Eric Buer
3+
week 2: Ian M Davis
4+
week 2: Schuyler Alan Schwafel
5+
week 3: James Brent Nunn
6+
week 3: Lauren Fries
7+
week 3: Lesley D Reece
8+
week 3: Michel Claessens
9+
week 4: Benjamin C Mier
10+
week 4: Robert W Perkins
11+
week 4: Vinay Gupta
12+
week 4: Wayne R Fukuhara
13+
week 5: Darcy Balcarce
14+
week 5: David Fugelso
15+
week 5: Henry B Fischer
16+
week 5: Kyle R Hart
17+
week 6: Aleksey Kramer
18+
week 6: Alexander R Galvin
19+
week 6: Gideon I Sylvan
20+
week 6: Hui Zhang
21+
week 7: Andrew P Klock
22+
week 7: Danielle G Marcos
23+
week 7: Ousmane Conde
24+
week 7: Salim Hassan Hamed
25+
week 8: Alireza Hashemloo
26+
week 8: Arielle R Simmons
27+
week 8: Eric W Westman
28+
week 8: Ryan J Albright
29+
week 9: Alexandra N Kazakova
30+
week 9: Erik Ivan Lottsfeldt
31+
week 9: Louis John Ascoli
32+
week 9: Ralph P Brand
33+
week 10: Bryan L Davis
34+
week 10: Carolyn J Evans
35+
week 10: Changqing Zhu

Examples/Session01/students.txt

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,36 @@
11
name: languages
2-
Albright, Ryan J :
3-
Ascoli, Louis John :
4-
Balcarce, Darcy :
5-
Brand, Ralph P :
6-
Buer, Eric :
7-
Claessens, Michel :
8-
Conde, Ousmane :
9-
Davis, Bryan L :
10-
Davis, Ian M :
11-
Evans, Carolyn J :
12-
Fischer, Henry B :
13-
Fries, Lauren :
14-
Fugelso, David :
15-
Fukuhara, Wayne R :
16-
Galvin, Alexander R :
17-
Gupta, Vinay :
18-
Hamed, Salim Hassan :
19-
Hart, Kyle R :
20-
Hashemloo, Alireza :
21-
Huynh, Chantal :
22-
Kazakova, Alexandra N :
23-
Klock, Andrew P :
24-
Kramer, Aleksey :
25-
Lottsfeldt, Erik Ivan :
26-
Marcos, Danielle G :
27-
Mier, Benjamin C :
28-
Nunn, James B :
29-
Perkins, Robert W :
30-
Reece, Lesley D :
31-
Schwafel, Schuyler Alan :
32-
Simmons, Arielle R :
2+
Albright, Ryan J : VBA,
3+
Ascoli, Louis John : Basic, assm, shell
4+
Balcarce, Darcy : matlab, autocad, python
5+
Brand, Ralph P : C, C++, SQL,
6+
Buer, Eric : matlab, VBA, SQL,
7+
Claessens, Michel : VBA, basic SQL, pascal, matlab
8+
Conde, Ousmane :
9+
Davis, Bryan L :
10+
Davis, Ian M : C++
11+
Evans, Carolyn J : SQL,
12+
Fischer, Henry B : C, VB, SQL, SAS,
13+
Fries, Lauren : python
14+
Fugelso, David : C, C++, C#, Java
15+
Fukuhara, Wayne R : VB,
16+
Galvin, Alexander R : shell, C++, python
17+
Gupta, Vinay : C, C++, shell
18+
Hamed, Salim Hassan : Java, R, SAS, VBA
19+
Hart, Kyle R : QBasic, HTML,
20+
Hashemloo, Alireza :Javascript, PHP, C++
21+
Huynh, Chantal : Basic, SQL, Stata
22+
Kazakova, Alexandra N : R, python,
23+
Klock, Andrew P : C++, R, perl
24+
Kramer, Aleksey :Java, R, shell
25+
Lottsfeldt, Erik Ivan : basic, fortran,
26+
Marcos, Danielle G : python
27+
Mier, Benjamin C : C++, C#,
28+
Nunn, James Brent : shell, SQL, perl, pl1
29+
Perkins, Robert W : fortran, pascal, stata, javascript, sql
30+
Reece, Lesley D : html, SQL, PLSQL, perl, shell
31+
Schwafel, Schuyler Alan : bash, python, perl, php
32+
Simmons, Arielle R : Scheme, Java, VBA, python
3333
Sylvan, Gideon I :
34-
Westman, Eric W :
35-
Zhang, Hui :
36-
Zhu, Changquing :
34+
Westman, Eric W : C#, PHP, SQL, javascript
35+
Zhang, Hui : FoxBase
36+
Zhu, Changqing : C,

Examples/Session01/test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
print x, y
55

6+
def f():
7+
x = 5
8+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/python
2+
3+
"""
4+
a really simple module to use to test reloading
5+
"""
6+
7+
this = "this2"
8+
that = "that"
9+
10+
def print_something():
11+
print "I'm printing something else"
12+

Examples/Session03/test_script.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env python
2+
3+
print "yes, it ran"
4+
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python
2+
3+
4+
def cigar_party(cigars, is_weekend):
5+
"""
6+
basic solution
7+
"""
8+
if is_weekend and cigars >= 40:
9+
return True
10+
elif 40 <= cigars <= 60:
11+
return True
12+
return False
13+
14+
15+
def cigar_party2(cigars, is_weekend):
16+
"""
17+
some direct return of bool result
18+
"""
19+
if is_weekend:
20+
return (cigars >= 40)
21+
else:
22+
return (cigars >= 40 and cigars <= 60)
23+
24+
25+
def cigar_party3(cigars, is_weekend):
26+
"""
27+
conditional expression
28+
"""
29+
return (cigars >= 40) if is_weekend else (cigars >= 40 and cigars <= 60)
30+
31+
if __name__ == "__main__":
32+
# some tests
33+
34+
assert cigar_party(30, False) is False
35+
assert cigar_party(50, False) is True
36+
assert cigar_party(70, True) is True
37+
assert cigar_party(30, True) is False
38+
assert cigar_party(50, True) is True
39+
assert cigar_party(60, False) is True
40+
assert cigar_party(61, False) is False
41+
assert cigar_party(40, False) is True
42+
assert cigar_party(39, False) is False
43+
assert cigar_party(40, True) is True
44+
assert cigar_party(39, True) is False
45+
46+
print "All tests passed"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CodingBat Solutions
2+
====================
3+
4+
A few selected solutions form teh codingbat site:
5+
6+
http://codingbat.com/python
7+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python
2+
3+
4+
def diff21(n):
5+
"""
6+
basic solution
7+
"""
8+
if n > 21:
9+
return 2 * (n - 21)
10+
else:
11+
return 21 - n
12+
13+
14+
def diff21b(n):
15+
"""
16+
direct return of conditional expression
17+
"""
18+
return 2 * (n - 21) if n > 21 else 21-n
19+
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env python
2+
3+
##############################
4+
## Warmup-1 > monkey_trouble
5+
6+
7+
def monkey_trouble(a_smile, b_smile):
8+
"""
9+
really simple solution
10+
"""
11+
if a_smile and b_smile:
12+
return True
13+
elif not a_smile and not b_smile:
14+
return True
15+
else:
16+
return False
17+
18+
19+
def monkey_trouble2(a_smile, b_smile):
20+
"""
21+
slightly more sophisticated
22+
"""
23+
if a_smile and b_smile or not (a_smile or b_smile):
24+
return True
25+
else:
26+
return False
27+
28+
29+
def monkey_trouble3(a_smile, b_smile):
30+
"""
31+
conditional expression -- kind of ugly in this case
32+
"""
33+
result = True if (a_smile and b_smile or not (a_smile or b_smile)) else False
34+
return result
35+
36+
37+
def monkey_trouble4(a_smile, b_smile):
38+
"""
39+
direct return of boolean result
40+
"""
41+
return a_smile and b_smile or not (a_smile or b_smile)
42+
43+
if __name__ == "__main__":
44+
# a few tests
45+
46+
## neat trick to test all versions:
47+
for test_fun in (monkey_trouble,
48+
monkey_trouble2,
49+
monkey_trouble3,
50+
monkey_trouble4):
51+
assert test_fun(True, True) is True
52+
assert test_fun(False, False) is True
53+
assert test_fun(True, False) is False
54+
assert test_fun(False, True) is False
55+
56+
print "All tests passed"

0 commit comments

Comments
 (0)