-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhomework4.py
More file actions
71 lines (63 loc) · 2.53 KB
/
homework4.py
File metadata and controls
71 lines (63 loc) · 2.53 KB
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
61
62
63
64
65
66
67
68
69
70
71
import imp
def grade(module,file_name):
print('*********\nFILE\n*********')
try:
print(module.get_dictionary('test.txt',type_ = 'file'))
print('')
print(module.get_dictionary('test.txt',type_ = 'file', single_word = True))
print('')
print(module.get_dictionary('test.txt',type_ = 'file', single_word = False))
print('')
except Exception as e:
print(e)
print("Error getting File")
print('*********\nTEXT\n*********')
try:
print(module.get_dictionary('hello this is\na test',type_ = 'text'))
print('')
print(module.get_dictionary('hello this is\na test',type_ = 'text', single_word = True))
print('')
print(module.get_dictionary('hello this is\na test',type_ = 'text', single_word = False))
print('')
except Exception as e:
print(e)
print("Error getting Text")
print('*********\nURL\n*********')
try:
print(module.get_dictionary('http://loripsum.net/api/plaintext',type_ = 'url'))
print('')
print(module.get_dictionary('http://loripsum.net/api/plaintext',type_ = 'url', single_word = True))
print('')
print(module.get_dictionary('http://loripsum.net/api/plaintext',type_ = 'url', single_word = False))
print('')
except Exception as e:
print(e)
print("Error getting URL")
print('*********\nCOMPUTER PLAYER\n*********')
try:
d = module.get_dictionary('this is a test',type_='text')
module.play_against_computer_guesser(solution='test', dictionary=d)
module.play_against_computer_guesser(solution='test', dictionary=d, guesses=['t','a','b','s','e','t'])
except Exception as e:
print(e)
print("Error playing computer")
print('*********\nHUMAN PLAYER\n*********')
try:
d = module.get_dictionary('ahoy matey',type_='text')
module.play_against_human_guesser(solution='test')
module.play_against_human_guesser(solution='test')
module.play_against_human_guesser(solution='a test')
module.play_against_human_guesser(dictionary=d)
except Exception as e:
print(e)
print("Error playing human")
def get_penalties():
return {
1 : (-5 , "Insufficient Comments."),
2 : (-20 , "Code has syntax errors."),
3 : (-10 , "Error using test source."),
4 : (-10 , "Error using file source."),
5 : (-10 , "Error using url source."),
6 : (-10 , "Error with computer player."),
7 : (-10 , "Error with human player.")
}