-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bite25.py
60 lines (50 loc) · 1.54 KB
/
Bite25.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import random
BITES = {6: 'PyBites Die Hard',
7: 'Parsing dates from logs',
9: 'Palindromes',
10: 'Practice exceptions',
11: 'Enrich a class with dunder methods',
12: 'Write a user validation function',
13: 'Convert dict in namedtuple/json',
14: 'Generate a table of n sequences',
15: 'Enumerate 2 sequences',
16: 'Special PyBites date generator',
17: 'Form teams from a group of friends',
18: 'Find the most common word',
19: 'Write a simple property',
20: 'Write a context manager',
21: 'Query a nested data structure'}
bites_done = {6, 10, 16, 18, 21}
class NoBitesAvailable(Exception):
pass
class Promo:
def __init__(self, bites_done=bites_done):
self.bites_done = bites_done
def _pick_random_bite(self):
if len(set(BITES.keys()) - self.bites_done) == 0:
raise NoBitesAvailable
sett = set(BITES.keys()) - self.bites_done
print(sett)
return random.choice(list(sett))
def new_bite(self):
self.bites_done.add(self._pick_random_bite())
print(self.bites_done)
cl = Promo(bites_done)
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())
print(cl.new_bite())