@@ -49,20 +49,16 @@ def bot(ted, question):
49
49
"""
50
50
# Init LED happy image
51
51
display .show (Image .HAPPY )
52
-
53
52
# This is an advanced topic as well however this little function
54
53
# cleans out the unnecessary global objects or variables on what
55
54
# we call the heap area in memory
56
55
gc .collect ()
57
-
58
56
# Init response object
59
- response = ''
60
-
57
+ response = ''
61
58
# We want to make sure that our dictionary database can
62
59
# find all values even if you use a capital letter
63
60
# so we convert everything to lowercase
64
61
question = question .lower ()
65
-
66
62
# If you type something other than an empty string that means
67
63
# question has a value so the rest of the code will continue
68
64
# on
@@ -74,7 +70,6 @@ def bot(ted, question):
74
70
# put the value in the _response object
75
71
response = [val for key , val in ted .items () if key in question ]
76
72
gc .collect ()
77
-
78
73
# If our bot got a response from us then make sure
79
74
# we trigger the speaking or suprised image so our bot
80
75
# can open its mouth to talk and then have our bot
@@ -90,8 +85,7 @@ def bot(ted, question):
90
85
display .show (Image .SURPRISED )
91
86
print ('BOT: That is not something I am familiar with.' )
92
87
say ('That is not something I am familiar with.' , speed = SPEED )
93
- display .show (Image .HAPPY )
94
-
88
+ display .show (Image .HAPPY )
95
89
gc .collect ()
96
90
97
91
@@ -104,22 +98,18 @@ def quiz_f(teq):
104
98
"""
105
99
# Init LED happy image
106
100
display .show (Image .HAPPY )
107
-
108
101
# This is an advanced topic as well however this little function
109
102
# cleans out the unnecessary global objects or variables on what
110
103
# we call the heap area in memory
111
104
gc .collect ()
112
-
113
105
# Init score object
114
106
score = 0
115
-
116
107
# Here we iterate through our quiz database
117
108
for key in teq :
118
109
print (key )
119
110
say (str (key ), speed = SPEED )
120
111
response = input ('ANSWER: ' )
121
- response = response .lower ()
122
-
112
+ response = response .lower ()
123
113
correct_answer = teq [key ].lower ()
124
114
if response == correct_answer :
125
115
display .show (Image .SURPRISED )
@@ -133,10 +123,8 @@ def quiz_f(teq):
133
123
say ('The correct answer is' , speed = SPEED )
134
124
say (str (teq [key ]), speed = SPEED )
135
125
display .show (Image .HAPPY )
136
-
137
126
time .sleep (1 )
138
127
gc .collect ()
139
-
140
128
# Here we reply to the student their score
141
129
display .show (Image .SURPRISED )
142
130
print ('You got {0} out of {1} correct!' .format (score , len (teq )))
@@ -145,7 +133,6 @@ def quiz_f(teq):
145
133
say ('out of' , speed = SPEED )
146
134
say (str (len (teq )), speed = SPEED )
147
135
say ('correct!' , speed = SPEED )
148
-
149
136
# If student got a perfect score respond appropriately
150
137
# or provide an encouring message to retry the quiz
151
138
if score == len (teq ):
@@ -160,8 +147,7 @@ def quiz_f(teq):
160
147
print ('You are doing a great job!' )
161
148
say ('You are doing a great job!' , speed = SPEED )
162
149
print ('I would LOVE for you to try again!' )
163
- say ('I would LOVE for you to try again!' , speed = SPEED )
164
-
150
+ say ('I would LOVE for you to try again!' , speed = SPEED )
165
151
# Display happy response at the end of the quiz
166
152
display .show (Image .HAPPY )
167
153
gc .collect ()
@@ -176,15 +162,12 @@ def quiz_m(teq):
176
162
"""
177
163
# Init LED happy image
178
164
display .show (Image .HAPPY )
179
-
180
165
# This is an advanced topic as well however this little function
181
166
# cleans out the unnecessary global objects or variables on what
182
167
# we call the heap area in memory
183
168
gc .collect ()
184
-
185
169
# Init score object
186
170
score = 0
187
-
188
171
# Here we iterate through our quiz database with multiple
189
172
# choice items
190
173
for key in teq :
@@ -193,21 +176,18 @@ def quiz_m(teq):
193
176
say (str (key ), speed = SPEED )
194
177
display .show (Image .HAPPY )
195
178
time .sleep (1 )
196
-
197
179
display .show (Image .SURPRISED )
198
180
print ('Press A for {0}.' .format (teq [key ][0 ]))
199
181
say ('Press Ayyy for' , speed = SPEED )
200
182
say (str (teq [key ][0 ]), speed = SPEED )
201
183
display .show (Image .HAPPY )
202
184
time .sleep (1 )
203
-
204
185
display .show (Image .SURPRISED )
205
186
print ('Touch the logo for {0}.' .format (teq [key ][1 ]))
206
187
say ('Toch the logo for' , speed = SPEED )
207
188
say (str (teq [key ][1 ]), speed = SPEED )
208
189
display .show (Image .HAPPY )
209
190
time .sleep (1 )
210
-
211
191
display .show (Image .SURPRISED )
212
192
print ('Press B for {0}.' .format (teq [key ][2 ]))
213
193
say ('Press B for' , speed = SPEED )
@@ -224,16 +204,14 @@ def quiz_m(teq):
224
204
response = 2
225
205
break
226
206
else :
227
- pass
228
-
207
+ pass
229
208
correct_answer = teq [key ][3 ]
230
209
display .show (Image .SURPRISED )
231
210
print ('You selected {0}.' .format (teq [key ][response ]))
232
211
say ('You selected' , speed = SPEED )
233
212
say (str (teq [key ][response ]), speed = SPEED )
234
213
display .show (Image .HAPPY )
235
214
time .sleep (1 )
236
-
237
215
if response == correct_answer :
238
216
display .show (Image .SURPRISED )
239
217
print ('CORRECT!' )
@@ -245,11 +223,9 @@ def quiz_m(teq):
245
223
print ('The correct answer is {0}.' .format (teq [key ][correct_answer ]))
246
224
say ('The correct answer is' , speed = SPEED )
247
225
say (str (teq [key ][correct_answer ]), speed = SPEED )
248
- display .show (Image .HAPPY )
249
-
226
+ display .show (Image .HAPPY )
250
227
time .sleep (1 )
251
- gc .collect ()
252
-
228
+ gc .collect ()
253
229
# Here we reply to the student their score
254
230
display .show (Image .SURPRISED )
255
231
print ('You got {0} out of {1} correct!' .format (score , len (teq )))
@@ -260,7 +236,6 @@ def quiz_m(teq):
260
236
say ('correct!' , speed = SPEED )
261
237
display .show (Image .HAPPY )
262
238
time .sleep (1 )
263
-
264
239
# If student got a perfect score respond appropriately
265
240
# or provide an encouring message to retry the quiz
266
241
display .show (Image .SURPRISED )
@@ -277,7 +252,6 @@ def quiz_m(teq):
277
252
say ('You are doing a great job!' , speed = SPEED )
278
253
print ('I would LOVE for you to try again!' )
279
254
say ('I would LOVE for you to try again!' , speed = SPEED )
280
-
281
255
# Display happy response at the end of the quiz
282
256
display .show (Image .HAPPY )
283
257
time .sleep (1 )
0 commit comments