2025 정보수업 학습목표
# 데이터 타입 관련 파이썬 퀴즈10 |
|||||
---|---|---|---|---|---|
이름 | 김인수 | 등록일 | 25.03.16 | 조회수 | 12 |
import random
# 데이터 타입 관련 퀴즈 quiz_list = [ { "question": "파이썬에서 문자열(str)의 예시는?", "options": [ "1. 123", "2. 12.3", "3. 'hello'", "4. True", "5. None" ], "answer": 3 }, { "question": "파이썬에서 정수형(int)을 올바르게 표현한 것은?", "options": [ "1. '100'", "2. 100", "3. 100.0", "4. True", "5. [100]" ], "answer": 2 }, { "question": "파이썬에서 리스트(list)의 기본 표현은?", "options": [ "1. {1, 2, 3}", "2. (1, 2, 3)", "3. [1, 2, 3]", "4. <1, 2, 3>", "5. #1,2,3" ], "answer": 3 }, { "question": "다음 중 'bool' 타입에 해당하지 않는 것은?", "options": [ "1. True", "2. False", "3. 0", "4. 'False'", "5. not True" ], "answer": 4 }, { "question": "다음 중 파이썬에서 'None'의 용도는?", "options": [ "1. 숫자 0을 의미함", "2. 빈 문자열을 의미함", "3. 정의되지 않은 값을 나타냄", "4. 오류를 의미함", "5. 주석을 나타냄" ], "answer": 3 }, { "question": "파이썬에서 튜플(tuple)의 예는?", "options": [ "1. [1, 2, 3]", "2. {1: 'a'}", "3. (1, 2, 3)", "4. '1, 2, 3'", "5. set(1,2,3)" ], "answer": 3 }, { "question": "딕셔너리(dict)의 기본 구조는?", "options": [ "1. ['a', 'b']", "2. ('a', 'b')", "3. {'a': 1, 'b': 2}", "5. a:1, b:2" ], "answer": 3 }, { "question": "다음 중 실수(float)형 데이터는?", "options": [ "1. 10", "2. '10.0'", "3. 10.0", "4. True", "5. None" ], "answer": 3 }, { "question": "다음 중 set(집합) 자료형은?", "options": [ "1. {1, 2, 3}", "2. [1, 2, 3]", "3. (1, 2, 3)", "4. {'a': 1}", "5. '1,2,3'" ], "answer": 1 }, { "question": "파이썬에서 type('123')의 결과는?", "options": [ "1. "2. "3. "4. "5. ], "answer": 3 }, ]
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() |
이전글 | # 변수선언 파이썬 퀴즈10 |
---|---|
다음글 | # 연산자 관련 파이썬 퀴즈 10 |