2025 정보수업 학습목표
# 변수선언 파이썬 퀴즈10 |
|||||
---|---|---|---|---|---|
이름 | 김인수 | 등록일 | 25.03.16 | 조회수 | 23 |
# 변수선언 파이썬 퀴즈10
import random
# 퀴즈 리스트 quiz_list = [ { "question": "다음 중 올바른 파이썬 변수 선언은?", "options": [ "1. int x = 10", "2. var x = 10", "3. x := 10", "4. x = 10", "5. let x = 10" ], "answer": 4 }, { "question": "다음 중 변수 이름으로 사용할 수 없는 것은?", "options": [ "1. _variable", "2. variable1", "3. 1variable", "4. variable_1", "5. Variable" ], "answer": 3 }, { "question": "파이썬 변수 이름으로 올바른 것은?", "options": [ "1. my-variable", "2. my variable", "3. myVariable", "4. my.variable", "5. my@variable" ], "answer": 3 }, { "question": "다음 중 파이썬 예약어로 변수 이름으로 사용할 수 없는 것은?", "options": [ "1. def", "2. lambda", "3. class", "4. return", "5. all of the above" ], "answer": 5 }, { "question": "파이썬 변수는 어떤 자료형을 지정해야 선언 가능한가?", "options": [ "1. 반드시 자료형을 명시해야 한다", "2. 자료형을 선언문에 적어야 한다", "3. 자동으로 자료형이 지정된다", "4. 자료형을 선언 후 변수에 할당한다", "5. 변수 선언은 반드시 함수 안에서만 가능하다" ], "answer": 3 }, { "question": "다음 중 변수 이름으로 사용할 수 있는 것은?", "options": [ "1. for", "2. while", "3. _while", "4. if", "5. return" ], "answer": 3 }, { "question": "파이썬에서 변수의 자료형을 확인하려면 어떤 함수를 사용해야 할까?", "options": [ "1. typeof()", "2. type()", "3. getType()", "4. checktype()", "5. datatypes()" ], "answer": 2 }, { "question": "다음 중 잘못된 변수 선언은?", "options": [ "1. x = 100", "2. name = 'Alice'", "3. age = twenty", "4. is_ok = True", "5. price = 10.5" ], "answer": 3 }, { "question": "파이썬에서 변수 이름은 대소문자를 구분할까?", "options": [ "1. 아니다", "2. 언어 설정에 따라 다르다", "3. 구분하지 않는다", "4. 구분한다", "5. 파이썬 버전에 따라 다르다" ], "answer": 4 }, { "question": "파이썬 변수에 여러 값을 한 줄에 할당하려면?", "options": [ "1. x = y = z = 0", "2. x == y == z == 0", "3. x, y, z == 0", "4. x = y, z = 0", "5. x; y; z = 0" ], "answer": 1 }, ]
def run_quiz(): score = 0 random.shuffle(quiz_list) # 퀴즈 순서를 랜덤하게 섞음 for idx, q in enumerate(quiz_list, 1): print(f"\n문제 {idx}. {q['question']}") for option in q['options']: print(option) try: user_answer = int(input("정답 번호를 입력하세요 (1-5): ")) if user_answer == q['answer']: print("? 정답입니다!") score += 1 else: print(f"? 오답입니다. 정답은 {q['answer']}번입니다.") except ValueError: print("?? 숫자를 입력해주세요.")
print(f"\n총 {len(quiz_list)}문제 중 {score}개 정답 맞춤!")
if __name__ == "__main__": run_quiz() |
이전글 | 중앙중 정보1-1 구글클래스룸 |
---|---|
다음글 | # 데이터 타입 관련 파이썬 퀴즈10 |