1. Exponents 지수법칙 |
|||||
---|---|---|---|---|---|
작성자 | 김인수 | 등록일 | 25.09.10 | 조회수 | 1 |
? --------------------------------------------------------------------------------------- import tkinter as tk import random
# --------------------------- # 퀴즈 데이터 (지수법칙 관련) # --------------------------- quiz_data = [ # [문제, 정답, 보기, 해설] ("지수법칙: a^m * a^n = a^(m+n) 이다.", "O", ["O", "X"], "같은 밑의 곱은 지수끼리 더한다."), ("지수법칙: a^m / a^n = a^(m*n) 이다.", "X", ["O", "X"], "지수 나눗셈은 뺄셈 a^(m-n)이다."), ("지수법칙: (a^m)^n = a^(m*n) 이다.", "O", ["O", "X"], "거듭제곱의 거듭제곱은 곱셈이다."), ("지수법칙: (ab)^n = a^n * b^n 이다.", "O", ["O", "X"], "곱의 지수는 각각 나눠서 곱한다."), ("지수법칙: a^0 = 0 이다. (단, a≠0)", "X", ["O", "X"], "a^0 = 1 이다."),
("2^3 * 2^2 = ?", "32", ["8", "16", "32", "64", "128"], "2^3 * 2^2 = 2^(3+2) = 2^5 = 32"), ("(3^2)^3 = ?", "729", ["27", "81", "243", "729", "6561"], "(3^2)^3 = 3^(2*3) = 3^6 = 729"), ("10^5 / 10^2 = ?", "1000", ["10", "100", "1000", "10000", "100000"], "10^5 / 10^2 = 10^(5-2) = 10^3 = 1000"), ("(2*5)^2 = ?", "100", ["10", "25", "50", "100", "125"], "(2*5)^2 = 10^2 = 100"), ("4^(1/2) = ?", "2", ["1", "2", "4", "8", "16"], "4^(1/2) = √4 = 2") ]
random.shuffle(quiz_data)
# --------------------------- # GUI 초기 설정 # --------------------------- root = tk.Tk() root.title("지수법칙 퀴즈") root.geometry("600x400")
score = 0 current = 0
question_label = tk.Label(root, text="", font=("Arial", 16), wraplength=500) question_label.pack(pady=20)
buttons_frame = tk.Frame(root) buttons_frame.pack(pady=10)
result_label = tk.Label(root, text="", font=("Arial", 14)) result_label.pack(pady=10)
score_label = tk.Label(root, text="점수: 0", font=("Arial", 14)) score_label.pack(pady=10)
# --------------------------- # 함수 정의 # --------------------------- def load_question(): global current if current < len(quiz_data): question, answer, options, explanation = quiz_data[current] question_label.config(text=f"Q{current+1}. {question}") result_label.config(text="")
for widget in buttons_frame.winfo_children(): widget.destroy()
for opt in options: btn = tk.Button(buttons_frame, text=opt, font=("Arial", 14), width=10, command=lambda c=opt: check_answer(c)) btn.pack(pady=5) else: question_label.config(text="퀴즈 종료!") result_label.config(text=f"최종 점수: {score}/{len(quiz_data)}") for widget in buttons_frame.winfo_children(): widget.destroy()
def check_answer(choice): global score, current question, answer, options, explanation = quiz_data[current] if choice == answer: score += 1 result_label.config(text=f"정답! ?\n{explanation}", fg="green") else: result_label.config(text=f"오답 ?\n정답은 {answer}\n{explanation}", fg="red")
score_label.config(text=f"점수: {score}") current += 1 root.after(2000, load_question)
# --------------------------- # 첫 문제 실행 # --------------------------- load_question() root.mainloop() ----------------------------------------------------------------------------------------
|
이전글 | 2. Two Linear Equations in Two Unkonwns. 1차 연립방정식 |
---|---|
다음글 | 자유학기 주제별 학습안내 |