Skip to content

Commit 0f57158

Browse files
committed
updated Session 1 -- more to do!
1 parent a3b2519 commit 0f57158

33 files changed

+830
-472
lines changed

Examples/README.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Example code, etc.
2+
3+
Random stuff here.
4+

Examples/Session01/test.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
x = 5
2+
y = 56
3+
4+
print x, y
5+

Examples/Session02/codingbat.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Coding Bat examples
2+
######################
3+
4+
Warmup-1 > monkey_trouble
5+
============================
6+
7+
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::
8+
9+
monkey_trouble(True, True) → True
10+
monkey_trouble(False, False) → True
11+
monkey_trouble(True, False) → False
12+
13+
14+
Warmup-1 > sleep_in
15+
=======================
16+
17+
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.
18+
19+
sleep_in(False, False) → True
20+
sleep_in(True, False) → False
21+
sleep_in(False, True) → True
22+
23+
24+
Warmup-1 > diff21
25+
=======================
26+
27+
Given an int n, return the absolute difference between n and 21, except return double the absolute difference if n is over 21.
28+
29+
diff21(19) → 2
30+
diff21(10) → 11
31+
diff21(21) → 0
32+
33+
Warmup-1 > makes10
34+
======================
35+
36+
Given 2 ints, a and b, return True if one if them is 10 or if their sum is 10.
37+
38+
makes10(9, 10) → True
39+
makes10(9, 9) → False
40+
makes10(1, 9) → True
41+
42+
Logic-1 > cigar_party
43+
======================
44+
45+
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.
46+
47+
cigar_party(30, False) → False
48+
cigar_party(50, False) → True
49+
cigar_party(70, True) → True
50+

Examples/Session04/format_test.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def print_msg(t):
2+
print ("the first %i numbers are: " + ", ".join(["%i"] * len(t)) ) % ((len(t),) + t)
3+

Examples/Session04/junk2.txt

Whitespace-only changes.

Examples/Session04/junkfile.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
some textsome more text
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This is a text file with very little in it
2+
but it at least has more than one line

Examples/Session04/test_file2.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
antoher simple text file
2+
still with jsut a couple lines in it

Examples/Session05/arg_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env python
2+
3+
import sys
4+
5+
print sys.argv
6+

Examples/Session06/class.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class C(object):
2+
x = 5
3+
def __init__(self, y):
4+
self.y = y
5+
def meth(self, z):
6+
return self.x + self.y + z
7+
8+

0 commit comments

Comments
 (0)