-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathe2a.py
More file actions
42 lines (34 loc) · 652 Bytes
/
Copy pathe2a.py
File metadata and controls
42 lines (34 loc) · 652 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# e2a.py
"""
Example code for python class.
"""
def dub(x):
"""
doubles x
"""
ret = x*2
return ret
def fib(count):
"""
generate Fibonacci numbers
stop when size exceds passed parrameter
"""
x1,x2 = 0,1
counter=0
while counter<count:
yield x1
x1,x2 = x2,x1+x2
counter += 1
raise StopIteration
if __name__=="__main__":
print "dub",
if dub(3) == 6:
print "pass"
else:
print "broken"
print "fib",
if list(fib(9)) == [0, 1, 1, 2, 3, 5, 8, 13, 21]:
print "pass"
print len(list(fib(9)))
else:
print "broken"