From 93f183f0fa2ac7b4793ce48c2efdea6b4676f603 Mon Sep 17 00:00:00 2001 From: RangHo Lee Date: Mon, 30 Oct 2023 09:38:04 +0100 Subject: [PATCH 1/2] [COR1010] Add homework 8 and 9 files --- COR1010/H8_1.py | 13 +++++++++++++ COR1010/H8_2.py | 17 +++++++++++++++++ COR1010/H8_3.py | 15 +++++++++++++++ COR1010/H9_1.py | 13 +++++++++++++ COR1010/H9_2.py | 33 +++++++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+) create mode 100644 COR1010/H8_1.py create mode 100644 COR1010/H8_2.py create mode 100644 COR1010/H8_3.py create mode 100644 COR1010/H9_1.py create mode 100644 COR1010/H9_2.py diff --git a/COR1010/H8_1.py b/COR1010/H8_1.py new file mode 100644 index 0000000..7eede0c --- /dev/null +++ b/COR1010/H8_1.py @@ -0,0 +1,13 @@ +def isSymmetric(word): + for l, r in zip(word, reversed(word)): + if l != r: + return False + return True + +word = input("Enter a word : ") +result = isSymmetric(word) + +if result: + print(f"{word} is symmetric") +else: + print(f"{word} is asymmetric") diff --git a/COR1010/H8_2.py b/COR1010/H8_2.py new file mode 100644 index 0000000..3985ac9 --- /dev/null +++ b/COR1010/H8_2.py @@ -0,0 +1,17 @@ +import random + +def password(length): + lowercase = "abcdefghijklmnopqrstuvwxyz" + uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + numbers = "0123456789" + symbols = "!@#$%^&*" + all = lowercase + uppercase + numbers + symbols + + selected = random.choice(uppercase) + for i in range(length-1): + selected += random.choice(all) + + return selected + +length = int(input("Enter the length of password : ")) +print("Password is", password(length)) diff --git a/COR1010/H8_3.py b/COR1010/H8_3.py new file mode 100644 index 0000000..7247bf3 --- /dev/null +++ b/COR1010/H8_3.py @@ -0,0 +1,15 @@ +def countChars(s): + occurances = {} + for c in s: + c = c.lower() + occurances[c] = occurances.get(c, 0) + 1 + + return occurances + +input_str = input("Enter string : ") +occurances = countChars(input_str) + +print("=" * 30) + +for c, n in occurances.items(): + print("{} : {}번 사용되었습니다.".format(c, n)) diff --git a/COR1010/H9_1.py b/COR1010/H9_1.py new file mode 100644 index 0000000..c83f056 --- /dev/null +++ b/COR1010/H9_1.py @@ -0,0 +1,13 @@ +scores = {} + +with open("score.txt", "r") as f: + for line in f: + course, score = line.split() + course = int(course) + score = int(score) + + if course not in scores or scores[course] < score: + scores[course] = score + +for course, score in scores.items(): + print("{} 번 : {} 점".format(course, score)) diff --git a/COR1010/H9_2.py b/COR1010/H9_2.py new file mode 100644 index 0000000..375559d --- /dev/null +++ b/COR1010/H9_2.py @@ -0,0 +1,33 @@ +input_file = open("word_game.txt", "r") + +for line in input_file: + word = line.strip() + + guess_history = ["*"] * len(word) + + found_attempts = failed_attempts = 0 + while found_attampts < len(word): + guess_char = input("추측하는 문자 하나를 입력 {}----> ".format(guess_history)) + + if guess_char in guess_history: + print("{}은(는) 이미 찾은 문자입니다.".format(guess_char)) + elif word.find(guess_char) < 0: + print("{}은(는) 존재하지 않는 문자입니다.".format(guess_char)) + failed_attempts += 1 + else: + i = word.find(guess_char) + while i >= 0: + guess_history[i] = guess_char + found_attempts += 1 + i = word.find(guess_char, i + 1) + + print("찾는 단어는 {}입니다.".format(word)) + print("{}번 찾기 실패하였습니다.".format(failed_attempts)) + should_continue = input("단어 맞추기를 계속하시겠습니까? ") + + if should_continue.lower() == "n": + break + + print() + +input_file.close() From 9296c5fc1e2d9d2d4d181f6269a85e35a3d17873 Mon Sep 17 00:00:00 2001 From: RangHo Lee Date: Mon, 30 Oct 2023 09:39:05 +0100 Subject: [PATCH 2/2] [doc] Update main README and ready for merge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 70509b6..fea3653 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,12 @@ | `EEE1002` | [C언어기초](EEE1002) | 2020-02 | 실습, 과제, 프로젝트 | | `COR1009` | [컴퓨팅사고력(전자과 전용)](COR1009) | 2020-01 | 실습, 프로젝트 | | `EEE2108` | [공학프로그래밍](EEE2108) | 2021-02 | 실습, 보고서, 프로젝트 | +| `COR1010` | [기초인공지능프로그래밍](COR1010) | 2023-01 | 실습, 과제, TA용 유틸리티 | ## 🏗️ 작업중인 과목 목록 | 과목코드 | 과목명 | 학기 | 현재까지 작성된 내용 | |---|---|---|---| -| `COR1010` | [기초인공지능프로그래밍](COR1010) | 2023-01 | 실습, 과제, TA용 유틸리티 | ## 📝 라이센스 및 면책 조항 Creative Commons License