# 고1(1,5,6,7,8)

## 171 days ago by nim_od

#1 import random #문제 생성부 #각 함수는 연쇄작용을 함. def problem_num(): #문제에 들어갈 값 범위 랜덤 함수 x3_a, x2_a, x1_a, x0_a = 0,0,0,0 x3_b, x2_b, x1_b, x0_b = 0,0,0,0 while x3_a * x2_a * x1_a * x0_a == 0: x3_a = randint(-5, 5) x2_a = randint(-5, 5) x1_a = randint(-5, 5) x0_a = randint(-5, 5) while x3_b * x2_b * x1_b * x0_b == 0: x3_b = randint(-5, 5) x2_b = randint(-5, 5) x1_b = randint(-5, 5) x0_b = randint(-5, 5) while x2_a==x2_b or x1_a==x1_b or x0_a==x0_b: x2_b = randint(-5, 5) x1_b = randint(-5, 5) x0_b = randint(-5, 5) A=x3_a*x^3+x2_a*x^2+x1_a*x+x0_a B=x3_b*x^3+x2_b*x^2+x1_b*x+x0_b num1 = randint(-3,3) num2 = randint(1,5) while num1 == 0: num1 = randint(-3,3) ans=num1*A+num2*(A-B) return ans, A, B, num1, num2 # 답과 문제 랜덤 값 반환 def problem_answer_list(): # 답안과 결합될 숫자(랜덤화 및 중복 값 제거)를 생성하는 함수 ans,A,B,num1,num2=problem_num() answer_set=set() while len(answer_set)!=4: n1=randint(-2,2)+num1 n2=randint(-2,2)+num2 if n1*n2==0: continue answer_set.add(n1*A+n1*(A-B)) answer_list=list(answer_set) answer_list.append(ans) return answer_list,A,B,num1,num2 min select_answer_list,A,B,num1,num2=problem_answer_list() answer=select_answer_list[4] random.shuffle(select_answer_list) #문제 show(html("<p>두 다항식 $A = %s$, $B = %s$에 대하여 $%sA+%s(A-B)$를 구하여라.</p>"%(latex(A),latex(B),num1,num2))) sp = LatexExpr('\\quad') spp = LatexExpr('\\qquad') show("1.", sp, select_answer_list[0], spp, "2.", sp, select_answer_list[1], spp, "3.", sp, select_answer_list[2], spp, "4.", sp, select_answer_list[3], spp, "5.", sp, select_answer_list[4]) #for i in range(len(select_answer_list)): # show("%s."%(i+1), sp, ye, latex(expand(select_answer_list[i]))) #답안 확인 @interact def _(answers = selector([(None, ""),(select_answer_list[0], "1"), (select_answer_list[1], "2"), (select_answer_list[2], "3"), (select_answer_list[3], "4"), (select_answer_list[4], "5")], buttons=True), auto_update=False): if answer == answers: show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안): <br>주어진 식 $%sA+%s(A-B)$를 정리하면 $%sA-%sB$가 된다.<br>따라서 $%s(%s)-%s(%s)$를 계산하면 정답을 구할 수 있다. <br>$\\therefore %sA+%s(A-B)=%s$"%(num1,num2,num1+num2,num2,num1+num2,latex(A),num2, latex(B),num1,num2,latex((num1+num2)*A-num2*B)))) show(html("<input type = 'hidden' name = 'checking' class = 'val_chk' value = '1'>")) elif answers == None: show(html("<p><span style='color:blue'>Please input your answer in the spaces above.</span></p><p>(위의 빈칸에 답을 입력하고 [Update(확인)] 버튼을 클릭하세요.)</p>")) else: show(html("<p><span style='color:red'>Incorrect(오답)</span></p><p>Answer(답안): <br>주어진 식 $%sA+%s(A-B)$를 정리하면 $%sA-%sB$가 된다.<br>따라서 $%s(%s)-%s(%s)$를 계산하면 정답을 구할 수 있다. <br>$\\therefore %sA+%s(A-B)=%s$"%(num1,num2,num1+num2,num2,num1+num2,latex(A),num2, latex(B),num1,num2,latex((num1+num2)*A-num2*B)))) show(html("<input type = 'hidden' name = 'checking' class = 'val_chk' value = '0'>"))

## Click to the left again to hide and once more to show the dynamic interactive window

#5 import random #문제 생성부 #각 함수는 연쇄작용을 함. def problem_num(): #문제에 들어갈 값 범위 랜덤 함수 num = randint(-5, 5) while num == 0: num = randint(-5, 5) var('x,y') func=x^3+3*num*x^2*y+3*num^2*x*y^2+num^3*y^3 return func,num # 답과 문제 랜덤 값 반환 def problem_answer_list(): # 답안과 결합될 숫자(랜덤화 및 중복 값 제거)를 생성하는 함수 func,num =problem_num() answer_set=set() while len(answer_set)!=4: n=randint(-3, 3)+num if n==num or n==0: continue function=x^3+3*n*x^2*y+3*n^2*x*y^2+n^3*y^3 answer_set.add(factor(function)) answer_list=list(answer_set) answer_list.append(factor(func)) return answer_list,func,num select_answer_list,func,num=problem_answer_list() answer=select_answer_list[4] random.shuffle(select_answer_list) #문제 show(html("<p>다항식 $%s$을 인수분해 하시오.</p>"%(latex(func)))) sp = LatexExpr('\\quad') spp = LatexExpr('\\qquad') show("1.", sp, select_answer_list[0], spp, "2.", sp, select_answer_list[1], spp, "3.", sp, select_answer_list[2], spp, "4.", sp, select_answer_list[3], spp, "5.", sp, select_answer_list[4]) #for i in range(len(select_answer_list)): # show("%s."%(i+1), sp, ye, latex(expand(select_answer_list[i]))) #답안 확인 @interact def _(answers = selector([(None, ""),(select_answer_list[0], "1"), (select_answer_list[1], "2"), (select_answer_list[2], "3"), (select_answer_list[3], "4"), (select_answer_list[4], "5")], buttons=True), auto_update=False): if answer == answers: show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안): <br>주어진 식 $%s$은 $%s$로 인수분해된다"%(latex(func),latex(answer)))) show(html("<input type = 'hidden' name = 'checking' class = 'val_chk' value = '1'>")) elif answers == None: show(html("<p><span style='color:blue'>Please input your answer in the spaces above.</span></p><p>(위의 빈칸에 답을 입력하고 [Update(확인)] 버튼을 클릭하세요.)</p>")) else: show(html("<p><span style='color:red'>Incorrect(오답)</span></p><p>Answer(답안): <br>주어진 식 $%s$은 $%s$로 인수분해된다"%(latex(func),latex(answer)))) show(html("<input type = 'hidden' name = 'checking' class = 'val_chk' value = '0'>"))

## Click to the left again to hide and once more to show the dynamic interactive window

#6 import random def problem_num(): #문제에 들어갈 값 범위 랜덤 함수 global x1,x2 x2 = randint(-5, 5) x1 = randint(-5, 5) while x2*x1 == 0: x2 = randint(-5, 5) x1 = randint(-5, 5) var('A,B') f(x)=x^4+A*x^3+x2*x^2+x1*x+B a,b=solve([f(1) == 0, f(-1) == 4], A, B)[0] a=a.rhs() b=b.rhs() answer_func=f(x).subs(A=a,B=b) facto=factor(answer_func) print(a,b) print(facto) print(f(x)) return f(x), a,b,answer_func # 답과 문제 랜덤 값 반환 def problem_answer_list(): # 답안과 결합될 숫자(랜덤화 및 중복 값 제거)를 생성하는 함수 f, a,b,answer_func =problem_num() answer_list=[] answer_list.append([a,b,factor(answer_func)]) while len(answer_list)!=5: _,_a,_b,_func = problem_num() answers=[_a,_b,factor(_func)] if answers in answer_list: continue answer_list.insert(0,answers) return answer_list,f, answer_func, a, b select_answer_list,f, answer_func, a, b=problem_answer_list() answer=select_answer_list[4] random.shuffle(select_answer_list) #문제 show(html("<p>다항식 $%s$는 $x-1$로 나누어 떨어지고, $x+1$로 나누었을 때의 나머지가 $4$이다. 상수 $a,b$의 값을 구하고, 이 다항식을 인수분해하시오.</p>"%(latex(f)))) sp = LatexExpr('\\quad') spp = LatexExpr('\\qquad') for i in range(5): show(html("<p>$%s,a = %s, b = %s , %s$</p>"%(i+1,select_answer_list[i][0], select_answer_list[i][1], latex(select_answer_list[i][2])))) #답안 확인 @interact def _(answers = selector([(None, ""),(select_answer_list[0], "1"), (select_answer_list[1], "2"), (select_answer_list[2], "3"), (select_answer_list[3], "4"), (select_answer_list[4], "5")], buttons=True), auto_update=False): if answer == answers: show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안): <br>나머지정리에 의해 $a=%s, b=%s$를 얻는다. 따라서 $%s=%s$이 된다."%(a,b,latex(answer_func),latex(factor(answer_func))))) show(html("<input type = 'hidden' name = 'checking' class = 'val_chk' value = '1'>")) elif answers == None: show(html("<p><span style='color:blue'>Please input your answer in the spaces above.</span></p><p>(위의 빈칸에 답을 입력하고 [Update(확인)] 버튼을 클릭하세요.)</p>")) else: show(html("<p><span style='color:red'>Incorrect(오답)</span></p><p>Answer(답안): <br>나머지정리에 의해 $a=%s, b=%s$를 얻는다. 따라서 $%s=%s$이 된다."%(a,b,latex(answer_func),latex(factor(answer_func))))) show(html("<input type = 'hidden' name = 'checking' class = 'val_chk' value = '0'>"))

## Click to the left again to hide and once more to show the dynamic interactive window

#7 import random def problem_num(): #문제에 들어갈 값 범위 랜덤 함수 global x1,x2,num x2 = randint(-5, 5) x0 = randint(-5, 5) num = randint(-5, 5) while x2*x0*num == 0: x2 = randint(-5, 5) x0 = randint(-5, 5) num = randint(-5, 5) f(x)=x^3+x2*x^2+x0 g(x)=x+num quo, rem = f.maxima_methods().divide(g) return f(x),g(x),quo,rem # 답과 문제 랜덤 값 반환 def problem_answer_list(): # 답안과 결합될 숫자(랜덤화 및 중복 값 제거)를 생성하는 함수 f,g,quo,rem =problem_num() answer_list=[] answer_list.append([quo,rem]) while len(answer_list)!=5: _f,_g,_quo,_rem = problem_num() answers=[_quo,_rem] if answers in answer_list: continue answer_list.insert(0,answers) return answer_list,f,g,quo,rem select_answer_list,f, g,quo,rem =problem_answer_list() answer=select_answer_list[4] random.shuffle(select_answer_list) #문제 show(html("<p>조립제법을 이용하여 다항식 $%s$를 일차식 $%s$로 나눌 때의 몫과 나머지를 구하여라.</p>"%(latex(f),latex(g)))) sp = LatexExpr('\\quad') spp = LatexExpr('\\qquad') for i in range(5): show(html("<p>%s,몫 = $%s$, 나머지 = $%s$</p>"%(i+1,latex(select_answer_list[i][0]), latex(select_answer_list[i][1])))) #답안 확인 @interact def _(answers = selector([(None, ""),(select_answer_list[0], "1"), (select_answer_list[1], "2"), (select_answer_list[2], "3"), (select_answer_list[3], "4"), (select_answer_list[4], "5")], buttons=True), auto_update=False): if answer == answers: show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안): <br>다항식 $%s$를 일차식 $%s$로 나눌 때의 몫은 $%s$이고 나머지는 $%s$이다."%(latex(f),latex(g),latex(quo),rem))) show(html("<input type = 'hidden' name = 'checking' class = 'val_chk' value = '1'>")) elif answers == None: show(html("<p><span style='color:blue'>Please input your answer in the spaces above.</span></p><p>(위의 빈칸에 답을 입력하고 [Update(확인)] 버튼을 클릭하세요.)</p>")) else: show(html("<p><span style='color:red'>Incorrect(오답)</span></p><p>Answer(답안): <br>나머지정리에 의해 $a=%s, b=%s$를 얻는다. 따라서 $%s=%s$이 된다."%(a,b,latex(answer_func),latex(factor(answer_func))))) show(html("<input type = 'hidden' name = 'checking' class = 'val_chk' value = '0'>"))

## Click to the left again to hide and once more to show the dynamic interactive window

#8 import random #문제 생성부 #각 함수는 연쇄작용을 함. def problem_num(): #문제에 들어갈 값 범위 랜덤 함수 x3 = randint(-5, 5) x2 = randint(-5, 5) x0 = randint(-5, 5) while x3 * x2 * x0 == 0: x3 = randint(-5, 5) X2 = randint(-5, 5) x0 = randint(-5, 5) var('k') f(x) = x3*x^3 - x2*x^2 + k*x + x0 ans=float(solve(f(-2)==f(1),k)[0].rhs()) if ans-int(ans)!=0: return problem_num() return int(ans),f(x),x3,x2,x0 # 답과 문제 랜덤 값 반환 def problem_answer_list(): # 답안과 결합될 숫자(랜덤화 및 중복 값 제거)를 생성하는 함수 k,f,x3,x2,x0=problem_num() answer_set=set() while len(answer_set)!=4: answer_set.add(randint(-15,15)+k) answer_list=list(answer_set) answer_list.append(k) return answer_list,f,x3,x2,x0 select_answer_list,f,x3,x2,x0=problem_answer_list() answer=select_answer_list[4] random.shuffle(select_answer_list) #문제 show(html("<p>다항식 $P(x) = %s$을 $x+2$와 $x-1$로 나누었을 때의 나머지가 서로 같을 때, 실수 $k$의 값은?</p>"%(latex(f)))) sp = LatexExpr('\\quad') spp = LatexExpr('\\qquad') ye = LatexExpr('k=') show("1.", sp, ye, select_answer_list[0], spp, "2.", sp, ye, select_answer_list[1], spp, "3.", sp, ye, select_answer_list[2], spp, "4.", sp, ye, select_answer_list[3], spp, "5.", sp, ye, select_answer_list[4]) #for i in range(len(select_answer_list)): # show("%s."%(i+1), sp, ye, latex(expand(select_answer_list[i]))) #답안 확인 @interact def _(answers = selector([(None, ""),(select_answer_list[0], "1"), (select_answer_list[1], "2"), (select_answer_list[2], "3"), (select_answer_list[3], "4"), (select_answer_list[4], "5")], buttons=True), auto_update=False): if answer == answers: show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안): <br>$P(x)$를 $x+2$로 나누었을 때의 나머지는 $P(-2)= %s + (%s) - 2k + (%s) = %s-2k$<br>$P(x)$를 $x-1$로 나누었을 때의 나머지는 $P(1)= %s + (%s) + k + (%s) = %s+k$<br>이때 $P(-2)=P(1)$이므로<br>$%s-2k=%s+k$ <br>$\\therefore k=%s$"%(x3*(-2), x2*(-2), x0, x3*(-2)+x2*(-2)+x0, x3, x2, x0, x3+x2+x0, x3*(-2)+x2*(-2)+x0, x3+x2+x0,answer))) show(html("<input type = 'hidden' name = 'checking' class = 'val_chk' value = '1'>")) elif answers == None: show(html("<p><span style='color:blue'>Please input your answer in the spaces above.</span></p><p>(위의 빈칸에 답을 입력하고 [Update(확인)] 버튼을 클릭하세요.)</p>")) else: show(html("<p><span style='color:red'>Incorrect(오답)</span></p><p>Answer(답안): <br>$P(x)$를 $x+2$로 나누었을 때의 나머지는 $P(-2)= %s + (%s) - 2k + (%s) = %s-2k$<br>$P(x)$를 $x-1$로 나누었을 때의 나머지는 $P(1)= %s + (%s) + k + (%s) = %s+k$<br>이때 $P(-2)=P(1)$이므로<br>$%s-2k=%s+k$ <br>$\\therefore k=%s$"%(x3*(-2), x2*(-2), x0, x3*(-2)+x2*(-2)+x0, x3, x2, x0, x3+x2+x0, x3*(-2)+x2*(-2)+x0, x3+x2+x0,answer))) show(html("<input type = 'hidden' name = 'checking' class = 'val_chk' value = '0'>"))

## Click to the left again to hide and once more to show the dynamic interactive window