def check_answer(x, y, op, result, user_choice): #dựa vào x, y, op, result, user_choice ===> True or False if user_choice == True and result == calc(x, y, op): return True elif user_choice == False and result != calc(x, y, op): return True else: return False
def check_answer(x, y, op, result, user_choice): if eval.calc(x, y, op) == result: if user_choice == True: return True elif user_choice == False: return False elif eval.calc(x, y, op) != result: if user_choice == True: return False elif user_choice == False: return True
def check_answer(x, y, op, display_result, user_choice): if user_choice == True: if display_result == calc(x, y, op): return True else: return False else: if display_result == calc(x, y, op): return False else: return True
def check_answer(x, y, op, display_res, user_choice): # user_choice: True/False nhiem vu la return ra True or False true_res = calc(x, y, op) if true_res == display_res: return user_choice else: return not user_choice
def check_answer(x, y, op, result, user_choice): display_res = calc(x, y, op) if result == display_res: return user_choice else: return not user_choice
def check_answer(x, y, op, result, user_choice): from eval import calc result_real = calc(x, y, op) if result_real == result and user_choice == True: return True if result_real != result and user_choice == False: return True else: return False
def generate_quiz(): op = choice(['+', '+', '+', '+', '-', '-', '-', '*', '/']) err = choice([-1, 0, 0, 1]) x = randint(1, 10) y = randint(1, 10) from eval import calc dis_play_result = calc(x, y, op) + err infor_list = [x, y, op, dis_play_result] return infor_list
def generate_quiz(): # Hint: Return [x, y, op, result] x = randint(1, 25) y = randint(1, 25) op = choice(['+', '-', '*', '/']) result = calc(x, y, op) z = choice([0, 1, -1]) disp = result + z return [x, y, op, disp]
def check_answer(x, y, op, display_result, user_choice): print(user_choice) # x, y, op, result = generate_quiz() result = eval.calc(x, y, op) if result == display_result and user_choice == True\ or result != display_result and user_choice == False: mark = True else: mark = False return mark
def check_answer(x, y, op, display_res, user_choice): true_res = calc(x, y, op) if true_res == display_res: return user_choice # if user_choice: #== True: # return True # else: # return False else: return not user_choice
def check_answer(x, y, op, result, user_choice): # user_choice :True or False true_res = calc(x, y, op) if true_res == result: return user_choice else: if user_choice: return False else: return True
def generate_quiz(): x = random.randint(1, 10) y = random.randint(1, 10) op = choice(["+", "-", "*", "/"]) # Hint: Return [x, y, op, result] result = eval.calc(x, y, op) error = choice([-1, 0, 1]) dis_result = result + error return [x, y, op, dis_result]
def generate_quiz(): # Hint: Return [x, y, op, result] x = randint(1, 10) y = randint(1, 10) op = choice(['+', '-', '*', '/']) err = [-1, 0, 1] result = calc(x, y, op) + choice(err) return ([x, y, op, result])
def generate_quiz(): # Hint: Return [x, y, op, result] x = randint(1, 10) y = randint(1, 10) op = choice(['+', '-', '*', '/']) res = calc(x, y, op) err = randint(-1, 1) display_res = res + err return [x, y, op, display_res]
def generate_quiz(): # Hint: Return [x, y, op, display_result] x = randint(1, 10) y = randint(1, 10) op = choice(['+', '-', '*', '/']) result = calc(x, y, op) error = choice([-1, 0, 1]) display_result = result + error return [x, y, op, display_result]
def generate_quiz(): #viết hàm generate_quiz để trả ra x, y, op, result random # Hint: Return [x, y, op, result] ops = ['+', '-', '*', '/'] x = randint(1, 10) y = randint(1, 10) op = choice(ops) err = randint(-1, 1) res = calc(x, y, op) + err return [x, y, op, res]
def generate_quiz(): x = random.randint(1, 10) y = random.randint(1, 10) op_list = ["+", "-", '*', '/'] op = choice(op_list) res = eval.calc(x, y, op) error_list = [-1, 1, 0] error = choice(error_list) result = res + error return [x, y, op, result]
def generate_quiz(): # Hint: Return [x, y, op, result] x = choice(range(1, 10)) y = choice(range(1, 10)) op = choice(["+", "-", "*", "/"]) result = calc(x, y, op) error = choice([-1, 0, 1]) display_result = result + error return [x, y, op, display_result]
def check_answer(x, y, op, result, user_choice): real = eval.calc(x, y, op) if result == real: if user_choice == True: return True else: return False else: if user_choice == False: return True else: return False
def check_answer(x, y, op, display_result, user_choice): result = calc(x, y, op) if user_choice: if result == display_result: return True else: return False elif not user_choice: if result != display_result: return True else: return False
def generate_quiz(): x = randint(1, 10) y = randint(1, 10) ops = ["+", "-", "*", "/"] op = choice(ops) result = calc(x, y, op) err = choice([-1, 0, 1]) return [x, y, op, result + err]
def generate_quiz(): x = randint(1, 10) y = randint(1, 10) op = ['+', '-', '*', '/'] ope = choice(op) res = calc(x, y, ope) error = randint(-1, 1) r = res + error return [x, y, ope, r]
def generate_quiz(): #Hint: Return [x, y, op, result] x = randint(1,10) y = randint(1,10) ops = ['+', '-', '*', '/'] op = choice(ops) result = eval.calc(x, y, op) errs = [-1, 0, 1] error = choice(errs) return [x, y, op, result + error]
def generate_quiz(): x = randint(1, 10) y = randint(1, 10) op = choice(['+', '-', '*', '/']) res = calc(x, y, op) error = choice([-1, 1]) display_res = res + error return [x, y, op, display_res]
def check_answer(x, y, op, result, user_choice): resu = calc(x, y, op) if result == resu: # if user_choice == True: # return True # else: # return False return user_choice else: # if user_choice == True: # return False # else: # return True return not user_choice
def check_answer(x, y, op, result, user_choice): x = randint(1, 10) y = randint(1, 10) op = ['+', '-', '*', '/'] ope = choice(op) res = calc(x, y, ope) if r == res: user_choice = True elif r != res: user_choice = False return [x, y, ope, r, user_choice]
def generate_quiz(): op = ["+", "-", "*", "/"] op = choice(op) x = randint(0, 10) if op == "/": y = randint(1, 10) else: y = randint(0, 10) error = [-1, 0, 1, 0] error = choice(error) display_result = calc(x, y, op) + error # Hint: Return [x, y, op, display_result] return [x, y, op, display_result]
# from eval import calc import eval print("* " * 20) # random x, y, op, err [-1, 0, 1] -> display_res x = randint(1, 10) y = randint(1, 10) op = ["+", "-", "*", "/"] rand_op = choice(op) err = [-1, 0, 1] rand_err = choice(err) display_res = 0 res = eval.calc(x, y, rand_op) # print out the equation display_res = res + rand_err print("{} {} {} = {}".format(x, rand_op, y, display_res)) print("* " * 20) # ask ques = input("Y/N? ").upper() # check if ques == "Y": if rand_err == 0:
from random import * import eval x = choice(range(1,10)) y = choice(range(1,10)) ops = ["+","-","*","/"] error = [-1,0,1] op = choice(ops) result = eval.calc(x,y,op) er = choice(error) screen_result = result + er print("{0} {1} {2} = {3}".format(x,op,y,screen_result)) ans = input("Y/N? :").upper() if (er == 0 and ans == "Y") or (er !=0 and ans =="N"): print("Yay") elif (er == 0 and ans == "N") or (er !=0 and ans =="Y"): print("You Are Wrong")
# from eval import calc import eval x = randint(1,10) y = randint(1,10) op = choice(['+','-','*','/']) error = [-1 ,0 , 1] err = choice(error) playing = True count = 5 while playing and 0<count <6 : count -= 1 res = 0 res = eval.calc(x, y, op) display_res = res + err print("{} {} {} = {}".format(x,op,y,display_res) ) ans = input("(Y/N) ").upper() if res == display_res and ans == "Y": print("True") playing = False elif res == display_res and ans == "N": print("Lose") continue elif res != display_res and ans == "Y": print("Lose") continue