Skip to content

Commit 2846879

Browse files
Update sb_sc.py
1 parent f27fc19 commit 2846879

File tree

1 file changed

+9
-34
lines changed

1 file changed

+9
-34
lines changed

sb_sc.py

+9-34
Original file line numberDiff line numberDiff line change
@@ -210,20 +210,16 @@ def bot(ted, question):
210210
"""
211211
# Init LED happy image
212212
display.show(Image.HAPPY)
213-
214213
# This is an advanced topic as well however this little function
215214
# cleans out the unnecessary global objects or variables on what
216215
# we call the heap area in memory
217216
gc.collect()
218-
219217
# Init response object
220218
response = ''
221-
222219
# We want to make sure that our dictionary database can
223220
# find all values even if you use a capital letter
224221
# so we convert everything to lowercase
225222
question = question.lower()
226-
227223
# If you type something other than an empty string that means
228224
# question has a value so the rest of the code will continue
229225
# on
@@ -235,7 +231,6 @@ def bot(ted, question):
235231
# put the value in the _response object
236232
response = [val for key, val in ted.items() if key in question]
237233
gc.collect()
238-
239234
# If our bot got a response from us then make sure
240235
# we trigger the speaking or suprised image so our bot
241236
# can open its mouth to talk and then have our bot
@@ -264,22 +259,18 @@ def quiz_f(teq):
264259
"""
265260
# Init LED happy image
266261
display.show(Image.HAPPY)
267-
268262
# This is an advanced topic as well however this little function
269263
# cleans out the unnecessary global objects or variables on what
270264
# we call the heap area in memory
271265
gc.collect()
272-
273266
# Init score object
274267
score = 0
275-
276268
# Here we iterate through our quiz database
277269
for key in teq:
278270
print(key)
279271
say(str(key), speed=SPEED)
280272
response = input('ANSWER: ')
281273
response = response.lower()
282-
283274
correct_answer = teq[key].lower()
284275
if response == correct_answer:
285276
display.show(Image.SURPRISED)
@@ -292,20 +283,17 @@ def quiz_f(teq):
292283
print('The correct answer is {0}.'.format(teq[key]))
293284
say('The correct answer is', speed=SPEED)
294285
say(str(teq[key]), speed=SPEED)
295-
display.show(Image.HAPPY)
296-
286+
display.show(Image.HAPPY)
297287
time.sleep(1)
298-
gc.collect()
299-
288+
gc.collect()
300289
# Here we reply to the student their score
301290
display.show(Image.SURPRISED)
302291
print('You got {0} out of {1} correct!'.format(score, len(teq)))
303292
say('You got', speed=SPEED)
304293
say(str(score), speed=SPEED)
305294
say('out of', speed=SPEED)
306295
say(str(len(teq)), speed=SPEED)
307-
say('correct!', speed=SPEED)
308-
296+
say('correct!', speed=SPEED)
309297
# If student got a perfect score respond appropriately
310298
# or provide an encouring message to retry the quiz
311299
if score == len(teq):
@@ -320,8 +308,7 @@ def quiz_f(teq):
320308
print('You are doing a great job!')
321309
say('You are doing a great job!', speed=SPEED)
322310
print('I would LOVE for you to try again!')
323-
say('I would LOVE for you to try again!', speed=SPEED)
324-
311+
say('I would LOVE for you to try again!', speed=SPEED)
325312
# Display happy response at the end of the quiz
326313
display.show(Image.HAPPY)
327314
gc.collect()
@@ -336,15 +323,12 @@ def quiz_m(teq):
336323
"""
337324
# Init LED happy image
338325
display.show(Image.HAPPY)
339-
340326
# This is an advanced topic as well however this little function
341327
# cleans out the unnecessary global objects or variables on what
342328
# we call the heap area in memory
343329
gc.collect()
344-
345330
# Init score object
346331
score = 0
347-
348332
# Here we iterate through our quiz database with multiple
349333
# choice items
350334
for key in teq:
@@ -353,21 +337,18 @@ def quiz_m(teq):
353337
say(str(key), speed=SPEED)
354338
display.show(Image.HAPPY)
355339
time.sleep(1)
356-
357340
display.show(Image.SURPRISED)
358341
print('Press A for {0}.'.format(teq[key][0]))
359342
say('Press Ayyy for', speed=SPEED)
360343
say(str(teq[key][0]), speed=SPEED)
361344
display.show(Image.HAPPY)
362345
time.sleep(1)
363-
364346
display.show(Image.SURPRISED)
365347
print('Touch the logo for {0}.'.format(teq[key][1]))
366348
say('Toch the logo for', speed=SPEED)
367349
say(str(teq[key][1]), speed=SPEED)
368350
display.show(Image.HAPPY)
369351
time.sleep(1)
370-
371352
display.show(Image.SURPRISED)
372353
print('Press B for {0}.'.format(teq[key][2]))
373354
say('Press B for', speed=SPEED)
@@ -385,15 +366,13 @@ def quiz_m(teq):
385366
break
386367
else:
387368
pass
388-
389369
correct_answer = teq[key][3]
390370
display.show(Image.SURPRISED)
391371
print('You selected {0}.'.format(teq[key][response]))
392372
say('You selected', speed=SPEED)
393373
say(str(teq[key][response]), speed=SPEED)
394374
display.show(Image.HAPPY)
395-
time.sleep(1)
396-
375+
time.sleep(1)
397376
if response == correct_answer:
398377
display.show(Image.SURPRISED)
399378
print('CORRECT!')
@@ -405,11 +384,9 @@ def quiz_m(teq):
405384
print('The correct answer is {0}.'.format(teq[key][correct_answer]))
406385
say('The correct answer is', speed=SPEED)
407386
say(str(teq[key][correct_answer]), speed=SPEED)
408-
display.show(Image.HAPPY)
409-
387+
display.show(Image.HAPPY)
410388
time.sleep(1)
411-
gc.collect()
412-
389+
gc.collect()
413390
# Here we reply to the student their score
414391
display.show(Image.SURPRISED)
415392
print('You got {0} out of {1} correct!'.format(score, len(teq)))
@@ -419,8 +396,7 @@ def quiz_m(teq):
419396
say(str(len(teq)), speed=SPEED)
420397
say('correct!', speed=SPEED)
421398
display.show(Image.HAPPY)
422-
time.sleep(1)
423-
399+
time.sleep(1)
424400
# If student got a perfect score respond appropriately
425401
# or provide an encouring message to retry the quiz
426402
display.show(Image.SURPRISED)
@@ -436,8 +412,7 @@ def quiz_m(teq):
436412
print('You are doing a great job!')
437413
say('You are doing a great job!', speed=SPEED)
438414
print('I would LOVE for you to try again!')
439-
say('I would LOVE for you to try again!', speed=SPEED)
440-
415+
say('I would LOVE for you to try again!', speed=SPEED)
441416
# Display happy response at the end of the quiz
442417
display.show(Image.HAPPY)
443418
time.sleep(1)

0 commit comments

Comments
 (0)