-
Notifications
You must be signed in to change notification settings - Fork 0
/
flashcard.py
52 lines (48 loc) · 1.44 KB
/
flashcard.py
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
50
51
52
#Flash Card app code.
#Imports spreadsheet into Dictionary and maps the words for each language
import numpy as np
#readcsv(filename,columns,datatype)
filename = "languages.csv"
data = np.genfromtxt(filename,delimiter=',',dtype="U30")
print(np.shape(data))
question1 = 'What is the word in ' + data[0,1] +'? '
question2 = 'What is the word in ' + data[0,2] +'? '
guess = 0
#While input is not a quit variable, print random index
while guess !='q':
index = np.random.randint(0,len(data))
print('The word in English is: ',data[index,0])
guess = input(question1)
if guess == 'q':
break
elif guess == data[index,1]:
print('Great job! You are correct!')
else:
guess = input('Sorry, try again: ')
if guess == 'q':
break
elif guess == data[index,1]:
print('Great job! You are correct!')
#continue
else:
print('Sorry, the correct word is: ',data[index,1],'. Next language!')
#continue
#continue
#Now try Norwegian
guess = input(question2)
if guess == 'q':
break
elif guess == data[index,2]:
print('Great job! You are correct!')
else:
guess = input('Sorry, try again: ')
if guess == 'q':
break
elif guess == data[index,2]:
print('Great job! You are correct!')
#continue
else:
print('Sorry, the correct word is: ',data[index,2],'. Next word!')
#continue
#Displays first language of word at random and creates buttons to display others
#loops back