미적분(10,15,23,29,26+27)

128 days ago by nim_od

#10 import random from fractions import Fraction def problem_num(): #문제에 들어갈 값 범위 랜덤 함수 global a,S,a1,r_1,r_2 a1= randint(2,9) #첫째 항 r_1 = randint(2,9) #공비: 분수 while gcd(a1,r_1)!=1 or a1==r_1: r_1 = randint(2,9) r_2=randint(1,r_1-1) #공비: 분자 while gcd(r_1,r_2)!=1: r_2=randint(1,r_1-1) r=r_2/r_1 #공비 a(n)=a1*(1/3)^(n - 1) var('n, k') S(n) = sum(a(k), k, 1, n) # 부분합 ans=limit(S(n), n = +oo) #급수 수렴 값 return str(ans) # 답과 문제 랜덤 값 반환 def problem_answer_list(): # 답안과 결합될 숫자(랜덤화 및 중복 값 제거)를 생성하는 함수 ans =problem_num() answer_list=[] answer_list.append(['수렴',ans]) answer_list.insert(0,['발산']) while len(answer_list)!=5: m=randint(2,3) j=randint(20,30) answers=['수렴',str(Fraction(j,m))] 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> $%s+\\cfrac {%s}{%s}+%s(\\cfrac {%s}{%s})^2+\\dots +%s(\\cfrac {%s}{%s})^{n-1}+\\dots$</p>"%(a1,a1*r_2,r_1,a1,r_2,r_1,a1,r_2,r_1))) 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> 주어진 급수는 등비급수로 일반항은 $a_n=%s(\\cfrac %s %s)^{n-1}$이다. <br>공비 $r$의 절댓값이 1보다 작으므로 해당 급수는 수렴하며, 등비급수의 합 공식을 이용하여 수렴 값을 구할 수 있다. <br> $\\Sigma^{\\infty}_{n=1} %s(\\cfrac %s %s)^{n-1}=\\lim_{n \\to \\infty} \\cfrac {%s(1-(\\cfrac {%s}{%s})^n)}{1-\\cfrac {%s}{%s}}=%s"%(a1,r_2,r_1,a1,r_2,r_1,a1,r_2,r_1,r_2,r_1,answer[1]))) 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_n=%s(\\cfrac %s %s)^{n-1}$이다. <br>공비 $r$의 절댓값이 1보다 작으므로 해당 급수는 수렴하며, 등비급수의 합 공식을 이용하여 수렴 값을 구할 수 있다. <br> $\\Sigma^{\\infty}_{n=1} %s(\\cfrac %s %s)^{n-1}=\\lim_{n \\to \\infty} \\cfrac {%s(1-(\\cfrac {%s}{%s})^n)}{1-\\cfrac {%s}{%s}}=%s"%(a1,r_2,r_1,a1,r_2,r_1,a1,r_2,r_1,r_2,r_1,answer[1]))) 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

#15 import random from fractions import Fraction def problem_num(): #문제에 들어갈 값 범위 랜덤 함수 n1 = randint(2,5) n2 = randint(-9, -1) while gcd(n1,abs(n2))!=1 or n1==n2: n2 = randint(-9, -1) n3 = randint(n1+1,9) f(x)=n1*x+n2 r(x)=f(x)/n3 ans1,ans2=solve(abs(r(x)) < 1, x)[0] ans1=str(ans1)[:-4] ans2=str(ans2)[4:] ans=ans1+' < x < '+ans2 return n1,n2,n3,f(x),r(x),ans # 답과 문제 랜덤 값 반환 def problem_answer_list(): # 답안과 결합될 숫자(랜덤화 및 중복 값 제거)를 생성하는 함수 n1,n2,n3,f,r,ans =problem_num() answer_list=[] answer_list.append(ans) while len(answer_list)!=5: _n1,_n2,_n3,_f,_r,answers =problem_num() if answers in answer_list: continue answer_list.insert(0,answers) return answer_list,n1,n2,n3,f,r select_answer_list,n1,n2,n3,f,r =problem_answer_list() answer=select_answer_list[4] select_answer_list.sort() #문제 show(html("<p>다음 등비급수가 수렴하도록 하는 $x$의 범위를 구하시오.<br>$\\Sigma^{\\infty}_{n=1} \\cfrac {(%s)^n} {%s^n}$</p>"%(latex(f),n3))) sp = LatexExpr('\\quad') spp = LatexExpr('\\qquad') for i in range(5): show(html("<p>%s. $%s$</p>"%(i+1,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> $\\Sigma^{\\infty}_{n=1} \\cfrac {(%s)^n} {%s^n}=\\Sigma^{\\infty}_{n=1} (\\cfrac {%s} {%s})^n$<br>등비급수는 공비의 절댓값이 1보다 작을 때 수렴하므로,<br> $ -1< \\cfrac {%s} {%s}<1 \\quad \\to \\quad %s<%s<%s \\quad \\to \\quad %s<%s x<%s$<br>$\\therefore %s$"%(latex(f),n3,latex(f),n3,latex(f),n3,-1*n3,latex(f),n3,-1*n3-n2,n1,n3-n2,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> $\\lim_{n \\to \\infty} {\\cfrac {%s n+%s}{%s %s n}}=\\lim_{n \\to \\infty} {\\cfrac {\\cfrac{%s n}{n}+\\cfrac{%s}{n}}{\\cfrac{%s}{n} +\\cfrac{{%s} n}{n}}}=%s$"%(n2,n4,n3,n1,n2,n4,n3,n1,answer[1]))) show(html("<input type = 'hidden' name = 'checking' class = 'val_chk' value = '0'>")) 
       
#0: solve_rat_ineq(ineq=abs(x/2-1/2) < 1) ('1', '') 1< x < Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_2.py", line 10, in <module> WYgXyhhbnN3ZXJzID0gc2VsZWN0b3IoWyhOb25lLCAiIiksKHNlbGVjdF9hbnN3ZXJfbGlzd\ FswXSwgIjEiKSwgKHNlbGVjdF9hbnN3ZXJfbGlzdFsxXSwgIjIiKSwgKHNlbGVjdF9hbnN3Z\ XJfbGlzdFsyXSwgIjMiKSwgKHNlbGVjdF9hbnN3ZXJfbGlzdFszXSwgIjQiKSwgKHNlbGVjd\ F9hbnN3ZXJfbGlzdFs0XSwgIjUiKV0sIGJ1dHRvbnM9VHJ1ZSksIGF1dG9fdXBkYXRlPUZhb\ HNlKToKICAgIGlmIGFuc3dlciA9PSBhbnN3ZXJzOgogICAgICAgIHNob3coaHRtbCgiPHA+P\ HNwYW4gc3R5bGU9J2NvbG9yOmJsdWUnPkNvcnJlY3Qo7KCV64u1KTwvc3Bhbj48L3A+PHA+Q\ W5zd2VyKOuLteyViCk6IDxicj4gJFxcbGltX3tuIFxcdG8gXFxpbmZ0eX0ge1xcY2ZyYWMge\ yVzIG4rJXN9eyVzICVzIG59fT1cXGxpbV97biBcXHRvIFxcaW5mdHl9IHtcXGNmcmFjIHtcX\ GNmcmFjeyVzIG59e259K1xcY2ZyYWN7JXN9e259fXtcXGNmcmFjeyVzfXtufSArXFxjZnJhY\ 3t7JXN9IG59e259fX09JXMkIiUobjIsbjQsbjMsbjEsbjIsbjQsbjMsbjEsYW5zd2VyWzFdK\ SkpCiAgICAgICAgc2hvdyhodG1sKCI8aW5wdXQgdHlwZSA9ICdoaWRkZW4nIG5hbWUgPSAnY\ 2hlY2tpbmcnIGNsYXNzID0gJ3ZhbF9jaGsnIHZhbHVlID0gJzEnPiIpKQoKCiAgICBlbGlmI\ GFuc3dlcnMgPT0gTm9uZToKICAgICAgICBzaG93KGh0bWwoIjxwPjxzcGFuIHN0eWxlPSdjb\ 2xvcjpibHVlJz5QbGVhc2UgaW5wdXQgeW91ciBhbnN3ZXIgaW4gdGhlIHNwYWNlcyBhYm92Z\ S48L3NwYW4+PC9wPjxwPijsnITsnZgg67mI7Lm47JeQIOuLteydhCDsnoXroKXtlZjqs6AgW\ 1VwZGF0ZSjtmZXsnbgpXSDrsoTtirzsnYQg7YG066at7ZWY7IS47JqULik8L3A+IikpCiAgI\ CAgICAgCiAgICBlbHNlOgogICAgICAgIHNob3coaHRtbCgiPHA+PHNwYW4gc3R5bGU9J2Nvb\ G9yOnJlZCc+SW5jb3JyZWN0KOyYpOuLtSk8L3NwYW4+PC9wPjxwPkFuc3dlcijri7XslYgpO\ iA8YnI+ICRcXGxpbV97biBcXHRvIFxcaW5mdHl9IHtcXGNmcmFjIHslcyBuKyVzfXslcyAlc\ yBufX09XFxsaW1fe24gXFx0byBcXGluZnR5fSB7XFxjZnJhYyB7XFxjZnJhY3slcyBufXtuf\ StcXGNmcmFjeyVzfXtufX17XFxjZnJhY3slc317bn0gK1xcY2ZyYWN7eyVzfSBufXtufX19P\ SVzJCIlKG4yLG40LG4zLG4xLG4yLG40LG4zLG4xLGFuc3dlclsxXSkpKQogICAgICAgIHNob\ 3coaHRtbCgiPGlucHV0IHR5cGUgPSAnaGlkZGVuJyBuYW1lID0gJ2NoZWNraW5nJyBjbGFzc\ yA9ICd2YWxfY2hrJyB2YWx1ZSA9ICcwJz4iKSk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in <module> File "/tmp/tmp4xrxYQ/___code___.py", line 44, in <module> show(html("<p>수열 $a_n=\\cfrac {%s n+%s}{%s %s n}$의 수렴, 발산을 판정하고 수렴하는 경우 그 극한값을 구하시오.</p>"%(n2,n4,n3,n1))) NameError: name 'n2' is not defined
#0: solve_rat_ineq(ineq=abs(x/2-1/2) < 1)
('1', '')
1< x <
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_2.py", line 10, in <module>
    WYgXyhhbnN3ZXJzID0gc2VsZWN0b3IoWyhOb25lLCAiIiksKHNlbGVjdF9hbnN3ZXJfbGlzdFswXSwgIjEiKSwgKHNlbGVjdF9hbnN3ZXJfbGlzdFsxXSwgIjIiKSwgKHNlbGVjdF9hbnN3ZXJfbGlzdFsyXSwgIjMiKSwgKHNlbGVjdF9hbnN3ZXJfbGlzdFszXSwgIjQiKSwgKHNlbGVjdF9hbnN3ZXJfbGlzdFs0XSwgIjUiKV0sIGJ1dHRvbnM9VHJ1ZSksIGF1dG9fdXBkYXRlPUZhbHNlKToKICAgIGlmIGFuc3dlciA9PSBhbnN3ZXJzOgogICAgICAgIHNob3coaHRtbCgiPHA+PHNwYW4gc3R5bGU9J2NvbG9yOmJsdWUnPkNvcnJlY3Qo7KCV64u1KTwvc3Bhbj48L3A+PHA+QW5zd2VyKOuLteyViCk6IDxicj4gJFxcbGltX3tuIFxcdG8gXFxpbmZ0eX0ge1xcY2ZyYWMgeyVzIG4rJXN9eyVzICVzIG59fT1cXGxpbV97biBcXHRvIFxcaW5mdHl9IHtcXGNmcmFjIHtcXGNmcmFjeyVzIG59e259K1xcY2ZyYWN7JXN9e259fXtcXGNmcmFjeyVzfXtufSArXFxjZnJhY3t7JXN9IG59e259fX09JXMkIiUobjIsbjQsbjMsbjEsbjIsbjQsbjMsbjEsYW5zd2VyWzFdKSkpCiAgICAgICAgc2hvdyhodG1sKCI8aW5wdXQgdHlwZSA9ICdoaWRkZW4nIG5hbWUgPSAnY2hlY2tpbmcnIGNsYXNzID0gJ3ZhbF9jaGsnIHZhbHVlID0gJzEnPiIpKQoKCiAgICBlbGlmIGFuc3dlcnMgPT0gTm9uZToKICAgICAgICBzaG93KGh0bWwoIjxwPjxzcGFuIHN0eWxlPSdjb2xvcjpibHVlJz5QbGVhc2UgaW5wdXQgeW91ciBhbnN3ZXIgaW4gdGhlIHNwYWNlcyBhYm92ZS48L3NwYW4+PC9wPjxwPijsnITsnZgg67mI7Lm47JeQIOuLteydhCDsnoXroKXtlZjqs6AgW1VwZGF0ZSjtmZXsnbgpXSDrsoTtirzsnYQg7YG066at7ZWY7IS47JqULik8L3A+IikpCiAgICAgICAgCiAgICBlbHNlOgogICAgICAgIHNob3coaHRtbCgiPHA+PHNwYW4gc3R5bGU9J2NvbG9yOnJlZCc+SW5jb3JyZWN0KOyYpOuLtSk8L3NwYW4+PC9wPjxwPkFuc3dlcijri7XslYgpOiA8YnI+ICRcXGxpbV97biBcXHRvIFxcaW5mdHl9IHtcXGNmcmFjIHslcyBuKyVzfXslcyAlcyBufX09XFxsaW1fe24gXFx0byBcXGluZnR5fSB7XFxjZnJhYyB7XFxjZnJhY3slcyBufXtufStcXGNmcmFjeyVzfXtufX17XFxjZnJhY3slc317bn0gK1xcY2ZyYWN7eyVzfSBufXtufX19PSVzJCIlKG4yLG40LG4zLG4xLG4yLG40LG4zLG4xLGFuc3dlclsxXSkpKQogICAgICAgIHNob3coaHRtbCgiPGlucHV0IHR5cGUgPSAnaGlkZGVuJyBuYW1lID0gJ2NoZWNraW5nJyBjbGFzcyA9ICd2YWxfY2hrJyB2YWx1ZSA9ICcwJz4iKSk="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single')
  File "", line 1, in <module>
    
  File "/tmp/tmp4xrxYQ/___code___.py", line 44, in <module>
    show(html("<p>수열 $a_n=\\cfrac {%s n+%s}{%s %s n}$의 수렴, 발산을 판정하고 수렴하는 경우 그 극한값을 구하시오.</p>"%(n2,n4,n3,n1)))
NameError: name 'n2' is not defined
#29 import random def problem_num(): #문제에 들어갈 값 범위 랜덤 함수 global a,a_list a_list=[[15,'\\cfrac {\\sqrt 6 - \\sqrt 4}{2}'],[30,'\\cfrac 1 2'],[45,'\\cfrac {\\sqrt 2}{2}'],[60,'\\cfrac {\\sqrt 3}{2}'],[75,'\\cfrac {\\sqrt 6 + \\sqrt 2}{4}'],[105,'\\cfrac {\\sqrt 6 + \\sqrt 2}{4}']] a=random.choice(a_list) return a # 답과 문제 랜덤 값 반환 def problem_answer_list(): # 답안과 결합될 숫자(랜덤화 및 중복 값 제거)를 생성하는 함수 ans =problem_num() answer_list=[a[1]] while len(answer_list)!=5: answers=random.choice(a_list) if answers[1] in answer_list: continue answer_list.insert(0,answers[1]) return answer_list select_answer_list =problem_answer_list() answer=select_answer_list[4] select_answer_list.sort() #문제 show(html("<p>삼각함수 $sin %s^{\\circ}$ 의 값을 구하시오.</p>"%(a[0]))) sp = LatexExpr('\\quad') spp = LatexExpr('\\qquad') for i in range(5): show(html("<p>%s. $%s$</p>"%(i+1,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: if a[0]==15: show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안):$sin 15^{\\circ}$<br>$=sin (60^{\\circ}-45^{\\circ}$<br>$=sin60^{\\circ} cos 45^{\\circ}-cos 60^{\\circ} sin45^{\\circ}$<br>$= \\cfrac {\\sqrt 3}{2}\\cdot \\cfrac {\\sqrt 2}{2}-\\cfrac {1}{2}\\cdot \\cfrac {\\sqrt 2}{2}$<br>$= %s$"%(answer))) elif a[0]==30: show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안):$sin30^{\\circ}=\\cfrac {1}{2}$")) elif a[0]==45: show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안):$sin45^{\\circ}=\\cfrac {\\sqrt 2}{2}$")) elif a[0]==60: show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안):$sin60^{\\circ}=\\cfrac {\\sqrt 3}{2}$")) elif a[0]==75: show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안):$sin 75^{\\circ}$<br>$=sin (30^{\\circ}+45^{\\circ})$<br>$=sin30^{\\circ} cos 45^{\\circ}+cos 30^{\\circ} sin45^{\\circ}$<br>$=\\cfrac {\\sqrt 1}{2}\\cdot \\cfrac {\\sqrt 2}{2}+\\cfrac {\\sqrt 3}{2}\\cdot \\cfrac {\\sqrt 2}{2}$<br>$= %s$"%(answer))) elif a[0]==105: show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안):$sin 105^{\\circ}$<br>$=sin (60^{\\circ}+45^{\\circ})$<br>$=sin60^{\\circ} cos 45^{\\circ}+cos 60^{\\circ} sin45^{\\circ}$<br>$=\\cfrac {\\sqrt 3}{2}\\cdot \\cfrac {\\sqrt 2}{2}+\\cfrac {1}{2}\\cdot \\cfrac {\\sqrt 2}{2}$<br>$= %s$"%(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> $f(x)=%s ln(x)$에서 <br>$f'(x)=%s ln(x)+ %s \\times \\cfrac 1 x=%s ln(x)+%s$<br>$\\therefore f'(1)=%s$"%(latex(g(x)),latex(dg(x)),latex(g(x)),latex(dg(x)),latex(g(x)/x),answer))) show(html("<input type = 'hidden' name = 'checking' class = 'val_chk' value = '0'>")) 
       
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "_sage_input_18.py", line 10, in <module> IFxcY2ZyYWMge1xcc3FydCAyfXsyfSQ8YnI+JD0lcyIlKGFuc3dlcikpKQogICAgICAgIAog\ ICAgICAgIHNob3coaHRtbCgiPGlucHV0IHR5cGUgPSAnaGlkZGVuJyBuYW1lID0gJ2NoZWNr\ aW5nJyBjbGFzcyA9ICd2YWxfY2hrJyB2YWx1ZSA9ICcxJz4iKSkKCgogICAgZWxpZiBhbnN3\ ZXJzID09IE5vbmU6CiAgICAgICAgc2hvdyhodG1sKCI8cD48c3BhbiBzdHlsZT0nY29sb3I6\ Ymx1ZSc+UGxlYXNlIGlucHV0IHlvdXIgYW5zd2VyIGluIHRoZSBzcGFjZXMgYWJvdmUuPC9z\ cGFuPjwvcD48cD4o7JyE7J2YIOu5iOy5uOyXkCDri7XsnYQg7J6F66Cl7ZWY6rOgIFtVcGRh\ dGUo7ZmV7J24KV0g67KE7Yq87J2EIO2BtOumre2VmOyEuOyalC4pPC9wPiIpKQogICAgICAg\ IAogICAgZWxzZToKICAgICAgICBzaG93KGh0bWwoIjxwPjxzcGFuIHN0eWxlPSdjb2xvcjpy\ ZWQnPkluY29ycmVjdCjsmKTri7UpPC9zcGFuPjwvcD48cD5BbnN3ZXIo64u17JWIKTogPGJy\ PiAkZih4KT0lcyBsbih4KSTsl5DshJwgPGJyPiRmJyh4KT0lcyBsbih4KSsgJXMgXFx0aW1l\ cyBcXGNmcmFjIDEgeD0lcyBsbih4KSslcyQ8YnI+JFxcdGhlcmVmb3JlIGYnKDEpPSVzJCIl\ KGxhdGV4KGcoeCkpLGxhdGV4KGRnKHgpKSxsYXRleChnKHgpKSxsYXRleChkZyh4KSksbGF0\ ZXgoZyh4KS94KSxhbnN3ZXIpKSkKICAgICAgICBzaG93KGh0bWwoIjxpbnB1dCB0eXBlID0g\ J2hpZGRlbicgbmFtZSA9ICdjaGVja2luZycgY2xhc3MgPSAndmFsX2NoaycgdmFsdWUgPSAn\ MCc+Iikp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single') File "", line 1, in <module> File "/tmp/tmpEN4G4V/___code___.py", line 58 show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(\ 답안):$sin60^{\\circ}=\\cfrac {\\sqrt 3}{2})) ^ SyntaxError: EOL while scanning string literal
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_18.py", line 10, in <module>
    IFxcY2ZyYWMge1xcc3FydCAyfXsyfSQ8YnI+JD0lcyIlKGFuc3dlcikpKQogICAgICAgIAogICAgICAgIHNob3coaHRtbCgiPGlucHV0IHR5cGUgPSAnaGlkZGVuJyBuYW1lID0gJ2NoZWNraW5nJyBjbGFzcyA9ICd2YWxfY2hrJyB2YWx1ZSA9ICcxJz4iKSkKCgogICAgZWxpZiBhbnN3ZXJzID09IE5vbmU6CiAgICAgICAgc2hvdyhodG1sKCI8cD48c3BhbiBzdHlsZT0nY29sb3I6Ymx1ZSc+UGxlYXNlIGlucHV0IHlvdXIgYW5zd2VyIGluIHRoZSBzcGFjZXMgYWJvdmUuPC9zcGFuPjwvcD48cD4o7JyE7J2YIOu5iOy5uOyXkCDri7XsnYQg7J6F66Cl7ZWY6rOgIFtVcGRhdGUo7ZmV7J24KV0g67KE7Yq87J2EIO2BtOumre2VmOyEuOyalC4pPC9wPiIpKQogICAgICAgIAogICAgZWxzZToKICAgICAgICBzaG93KGh0bWwoIjxwPjxzcGFuIHN0eWxlPSdjb2xvcjpyZWQnPkluY29ycmVjdCjsmKTri7UpPC9zcGFuPjwvcD48cD5BbnN3ZXIo64u17JWIKTogPGJyPiAkZih4KT0lcyBsbih4KSTsl5DshJwgPGJyPiRmJyh4KT0lcyBsbih4KSsgJXMgXFx0aW1lcyBcXGNmcmFjIDEgeD0lcyBsbih4KSslcyQ8YnI+JFxcdGhlcmVmb3JlIGYnKDEpPSVzJCIlKGxhdGV4KGcoeCkpLGxhdGV4KGRnKHgpKSxsYXRleChnKHgpKSxsYXRleChkZyh4KSksbGF0ZXgoZyh4KS94KSxhbnN3ZXIpKSkKICAgICAgICBzaG93KGh0bWwoIjxpbnB1dCB0eXBlID0gJ2hpZGRlbicgbmFtZSA9ICdjaGVja2luZycgY2xhc3MgPSAndmFsX2NoaycgdmFsdWUgPSAnMCc+Iikp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))' + '\n', '', 'single')
  File "", line 1, in <module>
    
  File "/tmp/tmpEN4G4V/___code___.py", line 58
    show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안):$sin60^{\\circ}=\\cfrac {\\sqrt 3}{2}))
                                                                                                                             ^
SyntaxError: EOL while scanning string literal
#26,27 import random from fractions import Fraction def problem_num(): #문제에 들어갈 값 범위 랜덤 함수 global n,k,q n= randint(2,9) #x 계수 k= randint(2,100) #상수 q= random.choice([1,2]) #문제 번호 return 0 # 답 반환 def problem_answer_list(): # 답안과 결합될 숫자(랜덤화 및 중복 값 제거)를 생성하는 함수 ans =problem_num() answer_list=['0'] while len(answer_list)!=5: answers=random.choice([n*k,Fraction(n,k),Fraction(k,n),n,k,'\\infty']) if str(answers) in answer_list: continue answer_list.insert(0,str(answers)) return answer_list select_answer_list =problem_answer_list() answer=select_answer_list[4] select_answer_list.sort() #문제 if q==1: show(html("<p>해당 식의 극한값을 구하시오.<br> $\\lim_{n \\to 0} {%s x^{%s}sin \\cfrac {1} {x}}$</p>"%(k,n))) else: show(html("<p>해당 식의 극한값을 구하시오.<br> $\\lim_{n \\to \\infty} { \\cfrac {%s cos x} {x^{%s}}}$</p>"%(k,n))) sp = LatexExpr('\\quad') spp = LatexExpr('\\qquad') for i in range(5): if select_answer_list[i]=='발산': show(html("<p>%s. %s</p>"%(i+1,select_answer_list[i]))) else: show(html("<p>%s. $%s$</p>"%(i+1,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: if q==1: show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안): $x \\ne 0$ 인 모든 실수 $x$에 대하여 <br>$-1 \\le sin \\cfrac 1 x \\le 1 \\qquad \\to \\qquad -%s \\le %s sin \\cfrac 1 x \\le %s \\qquad \\to \\qquad -%s x^{%s} \\le %s x^{%s}sin \\cfrac 1 x \\le %s x^{%s}$<br> $\\lim_{n \\to 0} {-x^{%s}}=\\lim_{n \\to 0} {x^{%s}}=0$<br>$ \\therefore \\lim_{n \\to 0} {%s x^{%s}sin \\cfrac 1 x}=0$"%(k,k,k,k,n,k,n,k,n,n,n,k,n))) p1 = plot(k*x^n*sin(1/x), (x, -0.5,0.5)) p2 = plot(-k*x^n, (x, -0.5,0.5), color = 'red') p3 = plot(k*x^n, (x, -0.5,0.5), color = 'green') show(p1 + p2 + p3) else: show(html("<p><span style='color:blue'>Correct(정답)</span></p><p>Answer(답안): $x \\ne 0$ 인 모든 실수 $x$에 대하여 <br> $-1 \\le cos x \\le 1 \\qquad \\to \\qquad -%s \\le %s cos x \\le %s \\qquad \\to \\qquad -\\cfrac {%s} {x^{%s}} \\le \\cfrac {%s cos x}{x^{%s}} \\le \\cfrac {%s} {x^{%s}}$<br> $\\lim_{n \\to \\infty} -{\\cfrac {%s} {x^{%s}}}=\\lim_{n \\to \\infty}{\\cfrac {%s} {x^{%s}}}=0 $<br>$\\therefore \\lim_{n \\to \\infty} {\\cfrac {%s cos x} {x^{%s}}}=0$"%(k,k,k,k,n,k,n,k,n,k,n,k,n,k,n))) p1 = plot(k*cos(x)/x^n, (x, -15,15)) p2 = plot(-1*k/x^n, (x, -15,15), color = 'red') p3 = plot(k/x^n, (x, -15,15), color = 'green') show(p1 + p2 + p3, ymax = 0.5, ymin = -0.5) 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: if q==1: show(html("<p><span style='color:red'>Incorrect(오답)</span></p><p>Answer(답안): $x \\ne 0$ 인 모든 실수 $x$에 대하여 <br>$-1 \\le sin \\cfrac 1 x \\le 1 \\qquad \\to \\qquad -%s \\le %s sin \\cfrac 1 x \\le %s \\qquad \\to \\qquad -%s x^{%s} \\le %s x^{%s}sin \\cfrac 1 x \\le %s x^{%s}$<br> $\\lim_{n \\to 0} {-x^{%s}}=\\lim_{n \\to 0} {x^{%s}}=0$<br>$ \\therefore \\lim_{n \\to 0} {%s x^{%s}sin \\cfrac 1 x}=0$"%(k,k,k,k,n,k,n,k,n,n,n,k,n))) p1 = plot(k*x^n*sin(1/x), (x, -1, 1)) p2 = plot(-k*x^n, (x, -1, 1), color = 'red') p3 = plot(k*x^n, (x, -1, 1), color = 'green') show(p1 + p2 + p3) else: show(html("<p><span style='color:red'>Incorrect(오답)</span></p><p>Answer(답안): $x \\ne 0$ 인 모든 실수 $x$에 대하여 <br> $-1 \\le cos x \\le 1 \\qquad \\to \\qquad -%s \\le %s cos x \\le %s \\qquad \\to \\qquad -\\cfrac {%s} {x^{%s}} \\le \\cfrac {%s cos x}{x^{%s}} \\le \\cfrac {%s} {x^{%s}}$<br> $\\lim_{n \\to \\infty} -{\\cfrac {%s} {x^{%s}}}=\\lim_{n \\to \\infty}{\\cfrac {%s} {x^{%s}}}=0 $<br>$\\therefore \\lim_{n \\to \\infty} {\\cfrac {%s cos x} {x^{%s}}}=0$"%(k,k,k,k,n,k,n,k,n,k,n,k,n,k,n))) p1 = plot(k*cos(x)/x^n, (x, -15,15)) p2 = plot(-1*k/x^n, (x, -15,15), color = 'red') p3 = plot(k/x^n, (x, -15,15), color = 'green') show(p1 + p2 + p3, ymax = 0.5, ymin = -0.5) show(html("<input type = 'hidden' name = 'checking' class = 'val_chk' value = '0'>")) 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