{ "catch, caught, caught":", , ", "fly, flew, flown":", " }
import sys import random
def main(): try: wordict = eval(open(sys.argv[1]).read()) # except: print "You have to enter all parameters.\nExample: python wordrepeater.py yourdictionary.json" # ? raw_input("")
mode = raw_input("Choose mode:\n\t1:Word To Translation;\n\t2:Translation To Word.\n>> "); if mode == "2": wordict = {wordict[k]:k for k in wordict.keys()} # .
def keysToValues(dic): # wrong = 0 # keys = dic.keys() # . while True: tmpkey = random.choice(keys) # print "{0}: {1}".format(len(keys), tmpkey) # . value = dic[tmpkey] # if raw_input("Translation: ") in value.split(", "): # "" , print "True. {0}\n".format(value) keys.remove(tmpkey) # ! ! . else: wrong += 1 print "Wrong! {0}\n".format(value) # ... . if len(keys) < 1: # . . raw_input("\n\nNothing\nWrong - {0}".format(wrong)) # sys.exit() # Enter,
keysToValues(wordict) if __name__ == "__main__": main()
import sys import random def keysToValues(dic): wrong = 0 right = 0 keys = dic.keys() while True: tmpkey = random.choice(keys) print "{0}: {1}".format(len(keys), tmpkey) #print str(len(keys))+":", tmpkey value = dic[tmpkey] #answ = raw_input("Translation: ") if raw_input("Translation: ") in value.split(", "): print "True. {0}\n".format(value) #fjf right += 1 keys.remove(tmpkey) else: wrong += 1 print "Wrong! {0}\n".format(value) if len(keys) < 1: raw_input("\n\nNothing\nRight - {0}. Wrong - {1}".format(right, wrong)) sys.exit() def main(): try: wordict = eval(open(sys.argv[1]).read()) except: print "You have to enter all parameters.\nExample: python wordrepeater.py yourdictionary.json" raw_input("") mode = raw_input("Choose mode:\n\t1:Word To Translation;\n\t2:Translation To Word.\n>> "); if mode == "2": wordict = {wordict[k]:k for k in wordict.keys()} elif mode == "": print "Exit" sys.exit() keysToValues(wordict) if __name__ == "__main__": main()
Source: https://habr.com/ru/post/211466/
All Articles