#13
import random
def problem_num(): #문제에 들어갈 값 범위 랜덤 함수
global n1,n2,n3,n4,f,f1,f2,f_list,ans
n1= randint(2,9)
n2 = randint(2,5)
while gcd(n1,n2)!=1 or n1==n2:
n2= randint(2,9)
n3 = randint(1,9)
n4 = randint(1,9)
f(n)=(n1*n+n3)/(n2*n+n4)
f1(n)=n1*n+n3
f2(n)=n2*n+n4
f_list=[[f1(i+1)/gcd(f1(i+1),f2(i+1)),f2(i+1)/gcd(f1(i+1),f2(i+1))] for i in range(3)]
ans=limit(f(n), n = +oo)
return ans # 답과 문제 랜덤 값 반환
def problem_answer_list(): # 답안과 결합될 숫자(랜덤화 및 중복 값 제거)를 생성하는 함수
ans =problem_num()
answer_list=[]
answer_list.append(['발산'])
answer_list.insert(0,['수렴',ans])
while len(answer_list)!=5:
answers=['수렴',randint(1,8)]
if answers in answer_list: continue
answer_list.insert(0,answers)
return answer_list
select_answer_list =problem_answer_list()
answer=select_answer_list[4]
select_answer_list.sort()
#문제
show(html("<p>다음 급수의 수렴, 발산을 조사하고, 수렴하면 그 합을 구하시오.<br> $\\cfrac {%s}{%s}+\\cfrac {%s}{%s}+\\cfrac {%s}{%s}+\\dots +\\cfrac {%s}{%s}+\\dots$</p>"%(f_list[0][0],f_list[0][1],f_list[1][0],f_list[1][1],f_list[2][0],f_list[2][1],latex(f1(n)),latex(f2(n)) )))
sp = LatexExpr('\\quad')
spp = LatexExpr('\\qquad')
for i in range(5):
if select_answer_list[i][0]=='발산':
show(html("<p>%s. %s</p>"%(i+1,select_answer_list[i][0])))
else:
show(html("<p>%s. %s, $%s$</p>"%(i+1,select_answer_list[i][0],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> 위 식을 일반화하면 $\\cfrac {%s}{%s}+\\cfrac {%s}{%s}+\\cfrac {%s}{%s}+\\dots +\\cfrac {%s}{%s}+\\dots=\\Sigma^{\\infty}_{n=1} \\cfrac {%s}{%s}$<br>$\\lim_{n \\to \\infty} \\cfrac {%s}{%s}=\\cfrac %s %s\\ne 0$이므로 해당 급수는 발산한다. "%(f_list[0][0],f_list[0][1],f_list[1][0],f_list[1][1],f_list[2][0],f_list[2][1],latex(f1(n)),latex(f2(n)),latex(f1(n)),latex(f2(n)),latex(f1(n)),latex(f2(n)),n1,n2)))
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> 위 식을 일반화하면 $\\cfrac {%s}{%s}+\\cfrac {%s}{%s}+\\cfrac {%s}{%s}+\\dots +\\cfrac {%s}{%s}+\\dots=\\Sigma^{\\infty}_{n=1} \\cfrac {%s}{%s}$<br>$\\lim_{n \\to \\infty} \\cfrac {%s}{%s}=\\cfrac %s %s\\ne 0$이므로 해당 급수는 발산한다. "%(f_list[0][0],f_list[0][1],f_list[1][0],f_list[1][1],f_list[2][0],f_list[2][1],latex(f1(n)),latex(f2(n)),latex(f1(n)),latex(f2(n)),latex(f1(n)),latex(f2(n)),n1,n2)))
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
|