Skip to content

Instantly share code, notes, and snippets.

@mikeckennedy
Last active February 18, 2017 15:15
Show Gist options
  • Save mikeckennedy/afdc50577f7299d392812a7a69a8cbbf to your computer and use it in GitHub Desktop.
Save mikeckennedy/afdc50577f7299d392812a7a69a8cbbf to your computer and use it in GitHub Desktop.
Feedback for a student :)
# Original version
def main():
name = print_intro()
the_list = bash_list.commands
flag='1'
while flag=='1':
random.shuffle(the_list)
correct, incorrect, answer_list = question_loop(the_list)
percentage = calculate_stats(correct, incorrect)
print_results(correct, incorrect, percentage, name)
if percentage < 100 or correct + incorrect < len(the_list):
the_list = remove_correct(the_list)
print('\nDo you want to practice the questions you missed or skipped?')
print('Enter 1 for Yes, or any other key to quit')
flag=input().rstrip()
else:
break
# Revised, pythonic? version
def main():
the_list = list(bash_list.commands) # make a copy, was changing original on line 27 via pointers
name = print_intro()
while True: # while true, use break
random.shuffle(the_list)
correct, incorrect, answer_list = question_loop(the_list)
percentage = calculate_stats(correct, incorrect)
print_results(correct, incorrect, percentage, name)
# reverse this list so the test is the if, success continues at the same level of indentation
if percentage >= 100 and correct + incorrect == len(the_list):
break # yay, they did it
the_list = remove_correct(the_list)
print() # new line here rather than embedded \n
print('Do you want to practice the questions you missed or skipped? [y]es or any key to exit: ')
ans = input().rstrip().lower() # lower for case insensativity
if ans != 'y' and ans != 'yes':
print("see you next time")
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment