-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNEW_PracticeFlashdeck.py
More file actions
49 lines (39 loc) · 1.7 KB
/
Copy pathNEW_PracticeFlashdeck.py
File metadata and controls
49 lines (39 loc) · 1.7 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
from filefinder import *
from random import *
from CommaManagement import *
def practiceFlashdeck():
printAllFlashdecks()
title = str(input("which flashcard set would you like to open? [press ENTER to exit]: "))
if title == '':
return None
else:
fTitle = 'flashdecks/' + title + ".txt"
try:
with open(fTitle, 'r') as f:
Flashdeck = [l for l in f]
shuffle(Flashdeck)
CorrectGuesses = 0
NumberOfQuestions = len(Flashdeck)
for l in Flashdeck:
FlashdeckWithoutDisplayedFlashcard = [ll for ll in Flashdeck if ll != l]
FlashcardQuestion = khmerconverter(l)
print('\n')
print('• ' + FlashcardQuestion[0])
UserInput = str(input("press [ENTER] to reveal answer"))
print('• ' + FlashcardQuestion[1])
while True:
UserInput = str(input('did you get the answer right? [Y/N]: '))
UserInput.lower().strip()
if UserInput == 'y':
CorrectGuesses += 1
break
elif UserInput == 'n':
break
else:
print('invalid input!')
print('\n')
print(f'final score: {CorrectGuesses}/{NumberOfQuestions} | {int(CorrectGuesses / NumberOfQuestions * 100)}%')
except FileNotFoundError:
print(f"{title} not found!")
if __name__ == "__main__":
practiceFlashdeck()