def main(): """主函数""" print("1.generate problem(默认)") print("2.quiz") print("3.exit") while True: is_int = True mode = input("请输入generate problem or solve problem or quiz or exit: ") # 生成问题 if mode == "1": print("1.int(默认)") print("2.fraction") while True: problem = input("请输入int or fraction: ") if problem == "1": break elif problem == "2": is_int = False break else: print("error: input should be int or fraction") continue while True: num = input("请输入生成题目的数量: ") if num.isdigit(): num = int(num) break else: print("error: input should be a int") generate_problem(num=num, is_int=is_int) # 答题模式 elif mode == "2": modes = ["1", "2"] while True: show_style = input("请输入乘方运算符显示风格 1.** 2.^:") if show_style in modes: break else: print("errot: input should be ** or ^") show_style = int(show_style) while True: fraction = input("请输入测试类型 1.整数(默认) 2.分数:") if fraction in modes: break else: print("error: input should be 整数 or 分数") if int(fraction) == 1: is_int = True else: is_int = False quiz(show_style=show_style, is_int=is_int) # 退出 elif mode == "3": break # 错误输入 else: print("error: input should be generate problem or solve problem or quiz or exit") continue
def console_file_manager(): while True: # Вывод меню и обработка пользовательского ввода i_command = print_header() # В зависимости от того, какой пункт меню был выбран пользователем # вызвать соответствующую функцию # Создать папку if i_command == 1: fm.create_folder() # Удалить папку elif i_command == 2: fm.delete_folder() # Скопировать папку elif i_command == 3: fm.copy_folder() # Вывести содержимое папки на экран elif i_command == 4: fm.list_directory("all") # Вывести на экран список папок из папки elif i_command == 5: fm.list_directory("folder") # Вывести на экран список файлов из папки elif i_command == 6: fm.list_directory("file") # Вывести на экран информацию об операционной системе elif i_command == 7: fm.list_config() # Запустить создателя программ elif i_command == 8: fm.program_creator() # Запустить викторину elif i_command == 9: qz.quiz() # Запустить приложение "мой счет в банке" elif i_command == 10: ba.bank_account() # Изменить текущий каталог elif i_command == 11: fm.change_current_directory() # Сохранение содержимого текущего каталога elif i_command == 12: fm.save_current_directory() # Выйти из программы elif i_command == 13: break
def receiveMention(self, text, mentionID, userName): print "**** Receive new" print pp(text) print mentionID print userName print "00" if text in self.greetings: # テンプレート返答 print "01" self.capi.postReply(self.greetings[text], mentionID, userName) elif quiz.is_quiz(text,userName): # quiz中/開始中 print "02" self.capi.postReply(quiz.quiz(text,userName), mentionID, userName) else: # 返答生成 if self.capi.grade == 0: print "03" ca = gen_reply.generateReply(text) print "13" cv = self.convToTsuboLang(ca); print "09" self.capi.postReply(cv, mentionID, userName) else: print "04" ca = gen_reply.generateReply(text) print "876" cv = self.convToLouLang(ca) print "123" self.capi.postReply(cv, mentionID, userName) print "05";
def auto(self): global wordgroup global popupWindow wordgroup = "auto" global q q = quiz(db=db, udb=udb, wordgroup=wordgroup) popupWindow.dismiss()
def update_question(self): quiz_que1 = quiz() question_type = quiz.type_of_question(self) hardn = quiz.hardness_of_question(self) quiz_que1.update_question(2, 'Whar is Odd No : ', [6, 2, 4, 5], 4) que1 = quiz_que1.dict_of_question quiz.add_question_to_mcq_list(self =que1 ,que_type=question_type,hardness=hardn)
def add_question_to_test(self): # print('type_of_que',que_type) # print('hardness',hardness) quiz_que1 = quiz() question_type = quiz_que1.type_of_question() hardn = quiz_que1.hardness_of_question() # print('hhhhh',hardn) quiz_que1.update_question(1, 'What is even NO. : ', [1, 2, 3, 5], 2) que1 = quiz_que1.dict_of_question # print("que1", que1) quiz.add_question_to_mcq_list(self =que1 ,que_type=question_type,hardness=hardn)
def index(): # the beginning of the quiz, create quiz and init answer_list if 'spec' in request.vars.keys(): try: quizobj = Quiz.quiz(request.vars['spec']) session['quiz'] = cPickle.dumps(quizobj) except: return "No such quiz" # reset the login if 'login' in session.keys(): del session['login'] # if quiz does not exist, redirect to home page if not 'quiz' in session.keys(): redirect(URL(r=request, c='default')) #work around web2py session can't store instances problem: #see http://groups.google.com/group/web2py/browse_thread/thread/acec00df5cf27193 #and https://groups.google.com/forum/#!msg/web2py/dmN54cpMuXo/lufvxmaQMLUJ #this bug combines with the other one (see question/codeact.py), in that #updates to class static vars *do* get stored in session, somehow #FIXME: cache.ram might be more appropriate quizobj = cPickle.loads(session['quiz']) # check login in marked mode if 'login' in session.keys() and session['login'] != '': #FIXME: I think this should be a constructor parameter. But since #we don't know until after instantiation whether a quiz is practice mode, #it can't be. hmm. should a composer really have its own login function, #or should that be a separate concern? quizobj.initialize_log(session['login']) if not quizobj.practice_mode and 'login' not in session.keys(): redirect(URL(r=request, f='seng_auth')) else: session['login'] = '' html = quizobj.get_html(request.vars) session['quiz'] = cPickle.dumps(quizobj) return html
def main(): """Run through the entire game.""" score_one = None score_two = None score_three = None introduction() location = navigate() while True: if quiz_check(location, score_one, score_two, score_three) and location != 0: score_one, score_two, score_three = quiz(location, score_one, score_two, score_three) if (score_one is not None and score_two is not None and score_three is not None): if want_leaderboard_entry(): conn, c = db_create() leaderboard_entry(conn, c) show_leaderboard(conn, c) return else: if location != 0: input(""" You've done this room.""") location = navigate(location)
} def readfile(PATH): if os.path.isfile(PATH) and os.access(PATH, os.R_OK): PATH = open(PATH, 'r') return PATH.read() else: print "Either "+PATH+" is missing or is not readable" # 2 db class sqlite_file="./db" conn = sqlite3.connect(sqlite_file) c = conn.cursor() if __name__ == "__main__": lang ="./lang.py" lang = readfile(lang) # print lang # string = 'Wat is je leeftijd?' # quiz = quiz(lang) quiz = quiz() # quiz.age(string) # quiz.gender("Wat is je geslacht? man / vrouw ") #quiz.getquestion()
def advantage(self): global wordgroup wordgroup = "advantage" global q q = quiz(db=db, udb=udb, wordgroup=wordgroup) popupWindow.dismiss()
def rare(self): global wordgroup wordgroup = "rare" global q q = quiz(db=db, udb=udb, wordgroup=wordgroup) popupWindow.dismiss()
def common(self): global wordgroup wordgroup = "common" global q q = quiz(db=db, udb=udb, wordgroup=wordgroup) popupWindow.dismiss()
def basic(self): global wordgroup wordgroup = "basic" global q q = quiz(db=db, udb=udb, wordgroup=wordgroup) popupWindow.dismiss()
os.mkdir(folder_name) else: print(f'Папка {folder_name} уже есть') elif choice == '2': folder_name = input('Какую папку хотите удалить? ') os.rmdir(folder_name) elif choice == '3': folder_name = input('Какой файл хотите копировать? ') shutil.copy(folder_name, 'file_copy') elif choice == '4': directory = os.getcwd() print(f'В текущей директории {directory} находятся: ') for i in range(len(os.listdir(directory))): print(os.listdir(directory)[i]) elif choice == '5': f_list('dir_names') elif choice == '6': f_list('file_names') elif choice == '7': print(os_name.my_os()) elif choice == '8': print('информация об авторе - [email protected]') elif choice == '9': print(quiz.quiz()) elif choice == '10': personal_account() elif choice == '11': break else: print('Неверный пункт меню')
height=0.06, name='Message', ) # Quiz msg.text = 'QUIZ\nPress SPACE to start' msg.draw() win.flip() keys = event.waitKeys(keyList=('space', 'escape')) # check for quit: if "escape" in keys: core.quit() win.flip() core.wait(1) quiz(read_questions('quiz.txt'), win) # Determine reward probabilities try: n = int(info['Participant']) except ValueError: if random.random() < 0.5: rwrd_probs = {'pink': RWRD_PROB, 'blue': 1 - RWRD_PROB} else: rwrd_probs = {'pink': 1 - RWRD_PROB, 'blue': RWRD_PROB} else: if n % 2 == 0: rwrd_probs = {'pink': RWRD_PROB, 'blue': 1 - RWRD_PROB} else: rwrd_probs = {'pink': 1 - RWRD_PROB, 'blue': RWRD_PROB}