-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct_cli.py
More file actions
executable file
·66 lines (55 loc) · 1.51 KB
/
product_cli.py
File metadata and controls
executable file
·66 lines (55 loc) · 1.51 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/python
# -*- coding: utf_8 -*-
import os
import random
from Tkinter import *
dictionary = dict(map(lambda s:s.split(), open("dictionary").readlines()))
count = 0
score = 0
f1content = dictionary.keys()
f2content = dictionary.values()
##
Class Answer ():
while count < 20:
os.system('clear')
wordnum = random.randrange(len(f1content))
print 'Слово:', f1content[wordnum], ''
options = [random.randrange(len(f2content)), random.randrange(len(f2content)), random.randrange(len(f2content))]
options[random.randrange(3)] = wordnum
print '1 -', f2content[options[0]],
print '2 -', f2content[options[1]],
print '3 -', f2content[options[2]],
answer = input('\n Ваш выбор:')
###
###
if options[answer-1] == wordnum:
raw_input('\n Верно! Нажмите enter...')
score += 1
else:
raw_input('\n Неверно! Нажмите enter...')
count += 1
print '\n Набрано очков:', score
obj=Answer
def b1_click ():
global answer
answer=1
# return answer
def b2_click ():
global answer
answer=2
# return answer
def b3_click ():
#global answer
answer=3
# return answer
window=Tk()
window.title("Viet nam trainer")
button1=Button(window,text='1',width=25,height=5,command=b1_click)
button2=Button(window,text='2',width=25,height=5,command=b2_click)
button3=Button(window,text='3',width=25,height=5,command=b3_click)
label = Label(font='sans 20',text=answer)
label.pack()
button1.pack()
button2.pack()
button3.pack()
window.mainloop()