Created
January 25, 2016 09:49
-
-
Save codeboy101/3c04be56c30512acbe49 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import datetime | |
| with open("questions.txt") as file: | |
| test_list = [x.split(':') for x in file.read().splitlines()] # the last element of the list created is [""] , the general format is : ["question","answer of the question"] . these values are unpacked as i and x with the for loop. but when the for loop comes to the last element which is [""] , there is an error, not enough values to unpack | |
| correct_count = 0 | |
| priority_list = [] | |
| time_taken = datetime.timedelta(seconds = 5) | |
| for i,x in test_list: | |
| print("{}".format(i)) | |
| when_asked = datetime.datetime.now() | |
| askUser = input() | |
| if askUser != x: | |
| continue | |
| correct_count += 1 | |
| when_told = datetime.datetime.now() | |
| intel_time = when_told - when_asked | |
| if intel_time > time_taken: | |
| priority_list.append(i) | |
| print("your score is {} , it took you {} ".format(correct_count,intel_time)) | |
| if priority_list: | |
| print("some questions seemed as if they took long to be answered ,") | |
| for questions in priority_list: | |
| print("--> {}".format(questions)) | |
| time.sleep(20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment