๐Ÿ˜ข ์Šคํ„ฐ๋””๋…ธํŠธ(Python ์ค‘๊ธ‰ ๋ฌธ์ œํ’€์ด 3~8)

zoeยท2023๋…„ 3์›” 13์ผ
0

๊ผญ๊ผญ ๋‹ค์‹œํ’€์–ด๋ณด๊ธฐ!! ๐Ÿ˜ฐ

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ๋ชจ๋“ˆ 04

  • ๐Ÿ’ก itertools :
    - from itertools import permutations โ†’ ์ˆœ์—ด ํ•จ์ˆ˜ ์‚ฌ์šฉ ๊ฐ€๋Šฅ, list๋ฅผ ์ž…๋ ฅํ•ด์•ผ ํ•˜๊ณ  list ํ˜•ํƒœ๋กœ ๋ฐ˜ํ™˜

๐Ÿ’ก ์ˆœ์—ด ๊ณ„์‚ฐ ๋ชจ๋“ˆ์„ ๋งŒ๋“ค๊ณ  ๋‹ค์Œ ์ˆœ์—ด ๊ณ„์‚ฐ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅ

# permultation ํŒŒ์ผ 

def getPermulatationCnt(n,r,logPrint = True):
    result = 1

    for n in range(n,n-r,-1):
        if logPrint == True: print('n : {}'.format(n)) # โ˜…โ˜…โ˜…
        result = result * n
    return result

from itertools import permutations

def gerPermultation(ns,r):

    pList = list(permutations(ns,r))
    print(f'{len(ns)}P{r} ๊ฐœ์ˆ˜ : {len(pList)}')

    for n in permutations(ns,r):
        print(n, end=',')

#  ์ˆœ์—ด ๊ณ„์‚ฐ ๋ชจ๋“ˆ์„ ๋งŒ๋“ค๊ณ  ๋‹ค์Œ ์ˆœ์—ด ๊ณ„์‚ฐ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅ

import permultation as pt

#n = int(input('numN ์ž…๋ ฅ : '))
#r = int(input('numR ์ž…๋ ฅ : '))

#print(f'{n}P{r} : {pt.getPermulatationCnt(n,r,logPrint=False)}')
listVar = {1,2,3,4,5,6,7,8}
rVar = 3
pt.gerPermultation(listVar, rVar)

[์—ฐ์Šต๋ฌธ์ œ] ๋ชจ๋“ˆ 05

  • ๐Ÿ’ก itertools :
    - from itertools import combinations โ†’ ์กฐํ•ฉ ํ•จ์ˆ˜ ์‚ฌ์šฉ ๊ฐ€๋Šฅ, list๋ฅผ ์ž…๋ ฅํ•ด์•ผ ํ•˜๊ณ  list ํ˜•ํƒœ๋กœ ๋ฐ˜ํ™˜

๐Ÿ’ก ์กฐํ•ฉ ๊ณ„์‚ฐ ๋ชจ๋“ˆ์„ ๋งŒ๋“ค๊ณ  ๋‹ค์Œ ์กฐํ•ฉ ๊ณ„์‚ฐ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅ

# combination ํŒŒ์ผ

def getCombination(n,r, logPrint = True):

    resultP = 1
    resultR = 1
    resultC = 1

    for i in range(n, n-r,-1):
        resultP  = resultP  * i

    if logPrint : print(f'resultP : {resultP}')

    for i in range(r, 0,-1):
        resultR  = resultR  * i
        if logPrint: print(f'resultR : {resultR}')

    resultC = int(resultP / resultR)
    if logPrint : print(f'result : {resultC}')

    return resultC



from itertools import combinations

def printCombinations(ns,r): #๋ฆฌ์ŠคํŠธ๋กœ ๋ฐ›์•„์•ผ ํ•จ(?)
    cList = list(combinations(ns,r))
    print(f'{len(ns)}C{r} : {len(cList)}')

    for i in combinations(ns,r):
        print(i, end=',')
# ์กฐํ•ฉ ๊ณ„์‚ฐ ๋ชจ๋“ˆ์„ ๋งŒ๋“ค๊ณ  ๋‹ค์Œ ์กฐํ•ฉ ๊ณ„์‚ฐ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅ

import combination as ct

numN = int(input('numN ์ž…๋ ฅ : '))
numR = int(input('numR ์ž…๋ ฅ : '))

#ct.getCombination(numN, numR)
print(f'{numN}C{numR} : {ct.getCombination(numN,numR, logPrint=False)}')


listVar = {1,2,3,4,5,6,7,8}
rVar = 3
ct.printCombinations(listVar, rVar)

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ๋ชจ๋“ˆ 06

๐Ÿ’ก ์ˆ˜์ž…๊ณผ ๊ณต๊ณผ๊ธˆ์„ ์ž…๋ ฅํ•˜๋ฉด ๊ณต๊ณผ๊ธˆ ์ด์•ก๊ณผ ์ˆ˜์ž… ๋Œ€๋น„ ๊ณต๊ณผ๊ธˆ ๋น„์œจ์„ ๊ณ„์‚ฐํ•˜๋Š” ๋ชจ๋“ˆ์„ ์ƒ์„ฑ

# utilitybill ํŒŒ์ผ
income = 0
waterPrice = 0; electricPrice = 0; gasPrice = 0

def setIncome(ic):
    global income # โ˜… ์„ ์–ธ ํ›„ ๊ฐ’์„ ํ• ๋‹นํ•ด์•ผ ํ•จ!
    income = ic

def getIncome():
    return income


def setWaterPrice(wp):
    global waterPrice
    waterPrice = wp

def getWaterPrice():
    return waterPrice


def setElectricPrice(ep):
    global electricPrice
    electricPrice = ep

def getElectricPrice():
    return electricPrice


def setGasPrice(gp):
    global gasPrice
    gasPrice = gp

def getGasPrice():
    return gasPrice

def getUtilityBill():
    result = waterPrice + electricPrice + gasPrice
    return result

def getUtilityRate():
    result = (getUtilityBill() / getIncome()) * 100
    return result

def getFormated(num):
    return format(num,',')
# ์ˆ˜์ž…๊ณผ ๊ณต๊ณผ๊ธˆ์„ ์ž…๋ ฅํ•˜๋ฉด ๊ณต๊ณผ๊ธˆ ์ด์•ก๊ณผ ์ˆ˜์ž… ๋Œ€๋น„ ๊ณต๊ณผ๊ธˆ ๋น„์œจ์„ ๊ณ„์‚ฐํ•˜๋Š” ๋ชจ๋“ˆ์„ ์ƒ์„ฑ

import utilitybill as ub

inputIncome = int(input('์ˆ˜์ž… ์ž…๋ ฅ : '))
ub.setIncome(inputIncome)
inputWaterPrice = int(input('์ˆ˜๋„์š”๊ธˆ ์ž…๋ ฅ : '))
ub.setWaterPrice(inputWaterPrice)
inputEletricPrice = int(input('์ „๊ธฐ์š”๊ธˆ ์ž…๋ ฅ : '))
ub.setElectricPrice(inputEletricPrice)
inputGasPrice = int(input('๊ฐ€์Šค์š”๊ธˆ ์ž…๋ ฅ : '))
ub.setGasPrice(inputGasPrice)

print(f'๊ณต๊ณผ๊ธˆ : {ub.getFormated(ub.getUtilityBill())}')
print('์ˆ˜์ž… ๋Œ€๋น„ ๊ณต๊ณผ๊ธˆ ๋น„์œจ : {} %'.format(ub.getUtilityRate()))

[์—ฐ์Šต๋ฌธ์ œ] ๋ชจ๋“ˆ 07

๋‹ค์Œ๊ณผ ๊ฐ™์ด ํŒจํ‚ค์ง€์™€ ๋ชจ๋“ˆ์„ ๋งŒ๋“ค๊ณ  ์—ฐ์‚ฐ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅ

# basic_operator ํŒŒ์ผ

def add(num1, num2):
    print(f'{num1} + {num2} = {num1 + num2}')
    return num1 + num2

def sub(num1, num2):
    print(f'{num1} - {num2} = {num1 - num2}')
    return num1 - num2

def mul(num1, num2):
    print(f'{num1} * {num2} = {round(num1 * num2,2)}')
    return num1 * num2

def div(num1, num2):
    print(f'{num1} / {num2} = {round(num1 / num2,2)}')
    return num1 / num2

def calculator(num1,num2):
    add(num1,num2)
    sub(num1,num2)
    mul(num1,num2)
    div(num1,num2)
# developer_operator ํŒŒ์ผ

def mod(num1, num2):
    print(f'{num1} % {num2} = {round(num1 % num2,2)}')
    return num1 % num2

def flo(num1, num2):
    print(f'{num1} // {num2} = {round(num1 // num2,2)}')
    return num1 // num2

def exp(num1, num2):
    print(f'{num1} ** {num2} = {round(num1 ** num2,2)}')
    return num1 ** num2

def calculator(num1,num2):
    mod(num1,num2)
    flo(num1,num2)
    exp(num1,num2)
# triangle_square_area ํŒŒ์ผ

def calculatorTriangleSquareArea(num1,num2):
    triangle = num1 * num2 / 2
    square = num1 * num2
    print('์‚ผ๊ฐํ˜• ๋„“์ด : {}' .format(round(triangle,1)))
    print('์‚ฌ๊ฐํ˜• ๋„“์ด : {}'.format(round(square, 1)))
    return [triangle,square]
# circle_area ํŒŒ์ผ

def calculatorCircleArea(num):
    print(f'์›์˜ ๋„“์ด : {num*num*3.14}')
    return num * num * 3.14
# ๋‹ค์Œ๊ณผ ๊ฐ™์ด ํŒจํ‚ค์ง€์™€ ๋ชจ๋“ˆ์„ ๋งŒ๋“ค๊ณ  ์—ฐ์‚ฐ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅ

import arithmetic.basic_operator as bo
import arithmetic.developer_operator as do
import shape.triangle_square_area as tsa
import shape.circle_area as ca


number1 = float(input('์ˆซ์ž1 ์ž…๋ ฅ : '))
number2 = float(input('์ˆซ์ž2 ์ž…๋ ฅ : '))
bo.calculator(number1,number2)
do.calculator(number1,number2)

width = float(input('์ˆซ์ž1 ์ž…๋ ฅ : '))
height = float(input('์ˆซ์ž1 ์ž…๋ ฅ : '))
tsa.calculatorTriangleSquareArea(width,height)

radius = float(input('๋ฐ˜์ง€๋ฆ„ ์ž…๋ ฅ : '))
ca.calculatorCircleArea(radius)

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ํด๋ž˜์Šค 01

๐Ÿ’ก ํšŒ์›๊ฐ€์ž… ํด๋ž˜์Šค์™€ ํšŒ์›์ •๋ณด๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค๊ณ  ํšŒ์›๊ฐ€์ž… ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„

# member ํŒŒ์ผ

class Member:
    def __init__(self, id, pw):
        self.id = id
        self.pw = pw


class MemberResitory:
    def __init__(self):
        self.members = {}

    def addMember(self, m):
        self.members[m.id] = m.pw # member์—์„œ ์„ ์–ธํ•œ ๊ฒƒ๊ณผ ๋™์ผํ•ด์•ผ ํ•œ๋‹ค

    def loginMember(self, id, pw):
        isMember = id in self.members

        if isMember and self.members[id] == pw:
            print('{id} : Log-in success!!')
        else:
            print('{id} : Log-in fail!!')

    def removeMember(self, id, pw):
        del self.members[id]

    def printMembers(self):
        for mk in self.members.keys():
            print(f'ID : {mk}')
            print(f'PW : {self.members[mk]}')
# ์ค‘๊ธ‰ - practice ํด๋ž˜์Šค 01

# ํšŒ์›๊ฐ€์ž… ํด๋ž˜์Šค์™€ ํšŒ์›์ •๋ณด๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค๊ณ  ํšŒ์›๊ฐ€์ž… ๋กœ๊ทธ์ธ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„

import member as mb

mems = mb.MemberResitory()

for i in range(3):
    mId = input('์•„์ด๋”” ์ž…๋ ฅ : ')
    mPw = input('๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ : ')

    mem = mb.Member(mId, mPw)
    mems.addMember(mem)

mems.printMembers()

mems.loginMember('abc@gmail.com','1234')
mems.loginMember('def@gmail.com','5678')
mems.loginMember('ghi@gmail.com','9012')

mems.removeMember('abc@gmail.com','1234')

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ํด๋ž˜์Šค 02

๐Ÿ’ก TVํด๋ž˜์Šค๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ƒ์† ๊ตฌ์กฐ๋กœ ๋งŒ๋“ค๊ณ  ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑ

# smartTv ํŒŒ์ผ

class NormalTv:
    def __init__(self, inch = 32, color = 'black', resolution = 'full-HD'):
        self.inch = inch
        self.color = color
        self.resolution = resolution
        self.smartTv = 'off'
        self.aiTv = 'off'

    def turnOn(self):
        print('TV power on!')

    def turnOff(self):
        print('TV power off!')

    def printTvInfo(self):
        print(f'inch : {self.inch} inch')
        print(f'color : {self.color}')
        print(f'resolution : {self.resolution}')
        print(f'smartTv : {self.smartTv}')
        print(f'aiTv : {self.aiTv}')


class Tv4K(NormalTv):
    def __init__(self,inch, color,resolution = '4K' ):
        super().__init__(inch,color,resolution)

    def setSmartTv(self,s):
        self.smartTv = s

class Tv8K(NormalTv):
    def __init__(self, inch, color, resolution = '8K'):
        super().__init__(inch,color,resolution)

    def setSmartTv(self,s):
        self.smartTv = s

    def setAiTv(self,s):
        self.aiTv = s
#  TVํด๋ž˜์Šค๋ฅผ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ƒ์† ๊ตฌ์กฐ๋กœ ๋งŒ๋“ค๊ณ  ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑ

import smartTv

my4kTv = smartTv.Tv4K(65,'silver','4k')
my4kTv.setSmartTv('on')
my4kTv.turnOn()
my4kTv.printTvInfo()
my4kTv.turnOff()

friendTv = my4kTv = smartTv.Tv4K(55,'white','4k')
friendTv.setSmartTv('off')
friendTv.turnOn()
friendTv.printTvInfo()
friendTv.turnOff()

my8KTv = smartTv.Tv8K(75,'black','8k')
my8KTv.setSmartTv('on')
my8KTv.setAiTv('on')
my8KTv.turnOn()
my8KTv.printTvInfo()
my8KTv.turnOff()

my8KTv = smartTv.Tv8K(86,'red','8k')
my8KTv.setSmartTv('on')
my8KTv.setAiTv('off')
my8KTv.turnOn()
my8KTv.printTvInfo()
my8KTv.turnOff()

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ํด๋ž˜์Šค 03

๐Ÿ’ก ๋‹ค์Œ ๋ช…์„ธ์„œ๋ฅผ ์ฐธ๊ณ ํ•ด์„œ ๋„์„œ ๊ด€๋ฆฌ ํ”„๋กœ๊ทธ๋žจ์„ ์ƒ์„ฑ

# book ํŒŒ์ผ

class Book:
    def __init__(self, name, price, isbn):
        self.bname = name
        self.bprice = price
        self.bisbn = isbn


class BookRepository:
    def __init__(self):
        self.bDic ={}

    def regisBook(self,book):
        self.bDic[book.bisbn] = book

    def removeBook(self,isbn):
        del self.bDic[isbn]

    def printBooksInfo(self):
        for i in self.bDic.keys():
            b = self.bDic[i]
            print(f'์ฑ… ์ด๋ฆ„ : {b.bname}')
            print(f'๊ฐ€๊ฒฉ ์ด๋ฆ„ : {b.bprice}')
            print(f'isbn ์ด๋ฆ„ : {b.bisbn}')

    def printBookInfo(self,isbn):
        if isbn in self.bDic:
            b = self.bDic[isbn]
            print(f'์ฑ… ์ด๋ฆ„ : {b.bname}')
            print(f'๊ฐ€๊ฒฉ ์ด๋ฆ„ : {b.bprice}')
            print(f'isbn ์ด๋ฆ„ : {b.bisbn}')
        else:
            print('lookup result does not exist')
#  ๋‹ค์Œ ๋ช…์„ธ์„œ๋ฅผ ์ฐธ๊ณ ํ•ด์„œ ๋„์„œ ๊ด€๋ฆฌ ํ”„๋กœ๊ทธ๋žจ์„ ์ƒ์„ฑ

import book

myBookRepository = book.BookRepository()

book1 = book.Book('python',20000,'123456')
myBookRepository.regisBook(book1)
myBookRepository.regisBook(book.Book('java',25000,'987456'))
myBookRepository.regisBook(book.Book('c++',30000,'942154'))
print()
myBookRepository.printBooksInfo()
myBookRepository.removeBook('123456')
print()
myBookRepository.printBooksInfo()
print()
myBookRepository.printBookInfo('987456')

[์—ฐ์Šต๋ฌธ์ œ] ํด๋ž˜์Šค 04

๋‹ค์Œ ์ถ”์ƒ ํด๋ž˜์Šค๋ฅผ ์ด์šฉํ•ด์„œ ํ•œ/์˜, ํ•œ/์ผ ์‚ฌ์ „ ํด๋ž˜์Šค๋ฅผ ์ƒ์„ฑ

# ADictionary ํŒŒ์ผ

from abc import ABCMeta
from abc import abstractmethod

class AbsDictionary(metaclass=ABCMeta):

    def __init__(self):
        self.wordDic = {}


    @abstractmethod
    def registWord(self, w1, w2):
        pass

    @abstractmethod
    def removeWord(self,w1):
        pass

    @abstractmethod
    def updateWord(self,w1,w2):
        pass

    @abstractmethod
    def searchWord(self, w1):
        pass


class KorToEng(AbsDictionary):

    def __init__(self):
        super().__init__() # โ˜…

    def registWord(self, w1, w2):
        print(f'[KorToEng] registWord() : {w1} to {w2}')
        self.wordDic[w1] = w2

    def removeWord(self,w1):
       print(f'[KorToEng] removeWord() : {w1}') # โ˜…
       del self.wordDic[w1]

    def updateWord(self,w1,w2):
        print(f'[KorToEng] updateWord() : {w1} to {w2}')
        self.wordDic[w1] = w2

    def searchWord(self, w1):
        print(f'[KorToEng] searchWord() : {w1}') # โ˜…
        return self.wordDic[w1]

    def printWords(self):
        for k in self.wordDic.keys(): # โ˜…
            print(f'{k} : {self.wordDic[k]}')


class KorToJpa(AbsDictionary):

    def __init__(self):
        super().__init__()  # โ˜…

    def registWord(self, w1, w2):
        print(f'[KorToJpa] registWord() : {w1} to {w2}')
        self.wordDic[w1] = w2

    def removeWord(self, w1):
        print(f'[KorToJpa] removeWord() : {w1}')
        del self.wordDic[w1]

    def updateWord(self, w1, w2):
        print(f'[KorToJpa] updateWord() : {w1} to {w2}')
        self.wordDic[w1] = w2

    def searchWord(self, w1):
        print(f'[KorToJpa] registWord() : {w1}')
        return self.wordDic[w1]

    def printWords(self):
        for k in self.wordDic.keys():
            print(f'{k} : {self.wordDic[k]}')
# ๋‹ค์Œ ์ถ”์ƒ ํด๋ž˜์Šค๋ฅผ ์ด์šฉํ•ด์„œ ํ•œ/์˜, ํ•œ/์ผ ์‚ฌ์ „ ํด๋ž˜์Šค๋ฅผ ์ƒ์„ฑ

import ADictionary as dic

kTe = dic.KorToEng()
kTe.registWord('์ฑ…','book')
kTe.registWord('๋‚˜๋น„','butterfly')
kTe.registWord('์—ฐํ•„','pencil')
kTe.registWord('ํ•™์ƒ','student')
kTe.registWord('์„ ์ƒ๋‹˜','teacher')

kTe.printWords()

kTe.updateWord('์ฑ…','Book')
kTe.printWords()

print(f'์ฑ… : {kTe.searchWord("์ฑ…")}')
print(f'๋‚˜๋น„ : {kTe.searchWord("๋‚˜๋น„")}')
print(f'์„ ์ƒ๋‹˜ : {kTe.searchWord("์„ ์ƒ๋‹˜")}')

kTe.removeWord('์ฑ…')
kTe.printWords()

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ํด๋ž˜์Šค 05

๐Ÿ’ก ์ฃผ์‚ฌ์œ„ ๊ฒŒ์ž„ ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค๊ณ  ์ปดํ“จํ„ฐ์™€ ์‚ฌ์šฉ์ž์˜ ๊ฒŒ์ž„ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅ

# Dice ํŒŒ์ผ 

import random as rd

class Dice:
    def __init__(self):
        self.cNum = 0
        self.uNum = 0

    def setCnum(self):
        print('[Dice] setCnum()')
        self.cNum = rd.randint(1,6)

    def setUnum(self):
        print('[Dice] setUnum()')
        self.uNum = rd.randint(1, 6)

    def startGame(self):
        print('[Dice] startGame()')

        self.setCnum()
        self.setUnum()

    def printResult(self):
        print('[Dice] printResult()')
        if self.cNum == 0 or  self.uNum == 0:
            print('์ฃผ์‚ฌ์œ„ ์ˆซ์ž ์„ค์ • ์ „์ž…๋‹ˆ๋‹ค.')
        else:
            if self.cNum > self.uNum:
                print(f'์ปดํ“จํ„ฐ vs ์œ ์ € : {self.cNum} vs {self.uNum} >> ์ปดํ“จํ„ฐ ์Šน!')
            if self.cNum < self.uNum:
                print(f'์ปดํ“จํ„ฐ vs ์œ ์ € : {self.cNum} vs {self.uNum} >> ์œ ์ € ์Šน!')
            if self.cNum == self.uNum:
                print(f'์ปดํ“จํ„ฐ vs ์œ ์ € : {self.cNum} vs {self.uNum} >> ๋ฌด์Šน๋ถ€!')์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š”
# ์ฃผ์‚ฌ์œ„ ๊ฒŒ์ž„ ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค๊ณ  ์ปดํ“จํ„ฐ์™€ ์‚ฌ์šฉ์ž์˜ ๊ฒŒ์ž„ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅ

import Dice

dc = Dice.Dice()
dc.startGame()
dc.printResult()

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ํด๋ž˜์Šค 06

๐Ÿ’ก ์ž๋™์ฐจ ๊ฒฝ์ฃผ ๊ฒŒ์ž„ ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์–ด ๋ณด์ž. ์ž๋™์ฐจ๋Š” ๋žœ๋คํ•˜๊ฒŒ ์ด๋™ํ•˜๋ฉฐ, ํŽธ์˜์ƒ 10์ดˆ ๋™์•ˆ ์ฃผํ–‰ํ•œ๋‹ค๊ณ  ํ•  ๋•Œ ๊ฐ€์žฅ ๋ฉ€๋ฆฌ ์ด๋™ํ•œ ์ž๋™์ฐจ๊ฐ€ ์šฐ์Šนํ•˜๋Š” ๊ฒŒ์ž„์ด๋‹ค

# car ํŒŒ์ผ

import random

class Car:
    def __init__(self, n='fire car', c = 'red', s = 200):
        self.name = n
        self.color = c
        self.max_speed = s
        self.distance = 0

    def printCarInfo(self):
        print(f'name : {self.name}, color : {self.color}, max_speed : {self.max_speed}')

    def controlSpeed(self):
        return random.randint(0, self.max_speed)

    def getDistanceForHour(self): # ํ•œ์‹œ๊ฐ„ ๋™์•ˆ ์ด๋™ํ•œ ๊ฑฐ๋ฆฌ
        return self.controlSpeed()*1
# racing ํŒŒ์ผ

from time import sleep

class CarRacing:

    def __init__(self):
        self.cars = []
        self.rankings = []

    def addCar(self,c):
        self.cars.append(c)

    def startRacing(self):
        for i in range(10):
            print(f'Racing : {i+1}๋ฐ”ํ€ด')
            for car in self.cars:
                car.distance += car.getDistanceForHour()
            sleep(1) # 1์ดˆ ๋™์•ˆ ์ž ์‹œ ์‰ผ
            self.printCurrentCarDistance()

    def printCurrentCarDistance(self):
        for car in self.cars:
            print(f'{car.name} : {car.distance}\t\t', end='')
        print()
# ์ž๋™์ฐจ ๊ฒฝ์ฃผ ๊ฒŒ์ž„ ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค์–ด ๋ณด์ž. ์ž๋™์ฐจ๋Š” ๋žœ๋คํ•˜๊ฒŒ ์ด๋™ํ•˜๋ฉฐ,
# ํŽธ์˜์ƒ 10์ดˆ ๋™์•ˆ ์ฃผํ–‰ํ•œ๋‹ค๊ณ  ํ•  ๋•Œ ๊ฐ€์žฅ ๋ฉ€๋ฆฌ ์ด๋™ํ•œ ์ž๋™์ฐจ๊ฐ€ ์šฐ์Šนํ•˜๋Š” ๊ฒŒ์ž„์ด๋‹ค

from car_games import racing as rc
from  car_games import car

myCarGame = rc.CarRacing()
car1 = car.Car('car01','white',250)
car2 = car.Car('car02','black',200)
car3 = car.Car('car03','yellow',220)
car4 = car.Car('car04','red',280)
car5 = car.Car('car05','blue',150)

myCarGame.addCar(car1)
myCarGame.addCar(car2)
myCarGame.addCar(car3)
myCarGame.addCar(car4)
myCarGame.addCar(car5)

myCarGame.startRacing()

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ํด๋ž˜์Šค 06

๐Ÿ’ก ๋‹ค์Œ๊ณผ ๊ฐ™์ด mp3 ํ”Œ๋ ˆ์ด์–ด ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค๊ณ  ๋…ธ๋ž˜ ๋“ฑ๋ก ํ›„ ์žฌ์ƒ

# mp3player ํŒŒ์ผ

from time import sleep
import random

class Song:

    def __init__(self, t, s, pt):
        self.title = t
        self.singer = s
        self.play_time = pt

    def printSongInfo(self):
        print(f'์ œ๋ชฉ : {self.title}, ๊ฐ€์ˆ˜ : {self.singer}, ์žฌ์ƒ์‹œ๊ฐ„ : {self.play_time}')


class Player:
    def __init__(self):
        self.songList = []
        self.isLoop = False

    def addSong(self, s):
        self.songList.append(s)

    def play(self):
        if self.isLoop:
            while self.isLoop:
                for song in self.songList:
                    print(f'title : {song.title}, singer : {song.singer}, play time : {song.play_time}')
                    sleep(song.play_time)
        else:
            for song in self.songList:
                print(f'title : {song.title}, singer : {song.singer}, play time : {song.play_time}')
                sleep(song.play_time)

    def shuffle(self):
        random.shuffle(self.songList)

    def setIsLoop(self, flag):
        self.isLoop = flag
# ๋‹ค์Œ๊ณผ ๊ฐ™์ด mp3 ํ”Œ๋ ˆ์ด์–ด ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค๊ณ  ๋…ธ๋ž˜ ๋“ฑ๋ก ํ›„ ์žฌ์ƒ

import mp3player as mp3

song1 = mp3.Song('์‹ ํ˜ธ๋“ฑ','์ด๋ฌด์ง„',3)
song2 = mp3.Song('Permission','๋ฐฉํƒ„์†Œ๋…„๋‹จ',4)
song3 = mp3.Song('Butter','๋ฐฉํƒ„์†Œ๋…„๋‹จ',2)
song4 = mp3.Song('Weekend','ํƒœ์—ฐ',5)
song5 = mp3.Song('์ข‹์•„์ข‹์•„','์กฐ์ •์„',4)

player = mp3.Player()
player.addSong(song1)
player.addSong(song2)
player.addSong(song3)
player.addSong(song4)
player.addSong(song5)

player.setIsLoop(False)
player.shuffle()
player.play()

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ์˜ˆ์™ธ์ฒ˜๋ฆฌ 01

๐Ÿ’ก ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์ˆซ์ž๋ฅผ ์ด์šฉํ•ด์„œ ์‚ฐ์ˆ ์—ฐ์‚ฐ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ๋ชจ๋“ˆ์„ ๋งŒ๋“ค๋˜, ์˜ˆ์ƒํ•˜๋Š” ์˜ˆ์™ธ์— ๋Œ€ํ•œ ์˜ˆ์™ธ์ฒ˜๋ฆฌ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑ

# calculator ํŒŒ์ผ 

def add(n1,n2) :
    print('๋ง์…ˆ ์—ฐ์‚ฐ')
    try:
        n1 = float(n1)
    except:
        print('์ฒซ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž๋Š” ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.')
        return  # โ˜…
    try:
        n2 = float(n2)
    except:
        print('๋‘ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž๋Š” ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.')
        return
    result = n1 + n2
    print(f'{n1} + {n2} = {result}')

def sub(n1,n2) :
    print('๋บ„์…ˆ ์—ฐ์‚ฐ')
    try:
        n1 = float(n1)
    except:
        print('์ฒซ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž๋Š” ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.')
        return  # โ˜…
    try:
        n2 = float(n2)
    except:
        print('๋‘ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž๋Š” ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.')
    result = n1 - n2
    print(f'{n1} - {n2} = {result}')

def mul(n1,n2) :
    print('๊ณฑ์…ˆ ์—ฐ์‚ฐ')
    try:
        n1 = float(n1)
    except:
        print('์ฒซ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž๋Š” ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.')
        return  # โ˜…
    try:
        n2 = float(n2)
    except:
        print('๋‘ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž๋Š” ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.')
    result = n1 * n2
    print(f'{n1} * {n2} = {result}')

def div(n1,n2) :
    print('๋‚˜๋ˆ—์…ˆ ์—ฐ์‚ฐ')
    try:
        n1 = float(n1)
    except:
        print('์ฒซ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž๋Š” ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.')
        return  # โ˜…
    try:
        n2 = float(n2)
    except:
        print('๋‘ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž๋Š” ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.')

    # if  n2 == 0:
    #     print(f'{n2}์œผ๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.')
    #     return  # โ˜…

    try:
        result = round(n1 / n2,1)
        print(f'{n1} / {n2} = {result}')
    except ZeroDivisionError as e:
        print(e)
        print(f'{n2}์œผ๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.')

def mod(n1,n2) :
    print('๋‚˜๋จธ์ง€ ์—ฐ์‚ฐ')
    try:
        n1 = float(n1)
    except:
        print('์ฒซ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž๋Š” ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.')
        return  # โ˜…
    try:
        n2 = float(n2)
    except:
        print('๋‘ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž๋Š” ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.')

    # if  n2 == 0:
    #     print(f'{n2}์œผ๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.')
    #     return  # โ˜…

    try:
        result = round(n1 % n2, 1)
        print(f'{n1} % {n2} = {result}')
    except ZeroDivisionError as e:
        print(e)
        print(f'{n2}์œผ๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.')

def flo(n1,n2) :
    print('๋ชซ ์—ฐ์‚ฐ')
    try:
        n1 = float(n1)
    except:
        print('์ฒซ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž๋Š” ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.')
        return  # โ˜…
    try:
        n2 = float(n2)
    except:
        print('๋‘ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž๋Š” ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.')

    # if  n2 == 0:
    #     print(f'{n2}์œผ๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.')
    #     return  # โ˜…

    try:
        result = round(n1 // n2, 1)
        print(f'{n1} // {n2} = {result}')
    except ZeroDivisionError as e:
        print(e)
        print(f'{n2}์œผ๋กœ ๋‚˜๋ˆŒ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.')

def exp(n1,n2) :
    print('๊ฑฐ๋“ญ์ œ๊ณฑ ์—ฐ์‚ฐ')
    try:
        n1 = float(n1)
    except:
        print('์ฒซ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž๋Š” ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.')
        return  # โ˜…
    try:
        n2 = float(n2)
    except:
        print('๋‘ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž๋Š” ์ˆซ์ž๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.')
    result = n1 ** n2
    print(f'{n1} ** {n2} = {result}')
# ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์ˆซ์ž๋ฅผ ์ด์šฉํ•ด์„œ ์‚ฐ์ˆ ์—ฐ์‚ฐ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ๋ชจ๋“ˆ์„ ๋งŒ๋“ค๋˜, ์˜ˆ์ƒํ•˜๋Š” ์˜ˆ์™ธ์— ๋Œ€ํ•œ ์˜ˆ์™ธ์ฒ˜๋ฆฌ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑ

import calculator as cc

num1 = input('์ฒซ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž ์ž…๋ ฅ : ')
num2 = input('๋‘ ๋ฒˆ์งธ ํ”ผ์—ฐ์‚ฐ์ž ์ž…๋ ฅ : ')

cc.add(num1,num2)
cc.sub(num1, num2)
cc.mul(num1, num2)
cc.div(num1, num2)
cc.mod(num1, num2)
cc.flo(num1, num2)
cc.exp(num1, num2)

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ์˜ˆ์™ธ์ฒ˜๋ฆฌ 02

๐Ÿ’ก 1๋ถ€ํ„ฐ 1000๊นŒ์ง€์˜ ์†Œ์ˆ˜์ธ ๋‚œ์ˆ˜ 10๊ฐœ๋ฅผ ์ƒ์„ฑํ•˜๋˜, ์†Œ์ˆ˜๊ฐ€ ์•„๋‹ˆ๋ฉด ์‚ฌ์šฉ์ž ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•˜๋„๋ก ํ”„๋กœ๊ทธ๋žจ์„ ์ƒ์„ฑ

# prime_module ํŒŒ์ผ

class NotPrimeException(Exception):

    def __init__(self,n):
        super().__init__(f'{n} is not prime number')
class PrimeException(Exception):

    def __init__(self,n):
        super().__init__(f'{n} is prime number')

def isPrime(number):
    flag = True
    for n in range(2, number):
        if number % n == 0:
            flag = False
            break
    if flag == False:
        raise NotPrimeException(number)
    else:
        raise PrimeException(number)
# 1๋ถ€ํ„ฐ 1000๊นŒ์ง€์˜ ์†Œ์ˆ˜์ธ ๋‚œ์ˆ˜ 10๊ฐœ๋ฅผ ์ƒ์„ฑํ•˜๋˜, ์†Œ์ˆ˜๊ฐ€ ์•„๋‹ˆ๋ฉด ์‚ฌ์šฉ์ž ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•˜๋„๋ก ํ”„๋กœ๊ทธ๋žจ์„ ์ƒ์„ฑ

import random
import prime_module as pm

primeNumbers = []

n = 0
while n < 10:
    rn = random.randint(2, 1000)
    if rn not in primeNumbers:
        try:
            pm.isPrime(rn)
        except pm.NotPrimeException as e:
            print(e)
            continue
        except pm.PrimeException as e:
            print(e)
            primeNumbers.append(rn)
    else:
        print(f'{rn} is overlap number')
        continue # โ˜…
    n +=1

print(f'PrimeNumbers : {primeNumbers}')

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ์˜ˆ์™ธ์ฒ˜๋ฆฌ 03

  • ๐Ÿ’ก globals() : ์ „์—ญ๋ณ€์ˆ˜ ๋ฐ˜ํ™˜

์ƒํ’ˆ ๊ตฌ๋งค์— ๋”ฐ๋ฅธ โ€˜์ด ๊ตฌ๋งค ๊ธˆ์•กโ€™์„ ์ถœ๋ ฅํ•˜๋˜, ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ฐœ์ˆ˜๊ฐ€ ์ž˜ ๋ชป ์ž…๋ ฅ๋œ ๊ฒฝ์šฐ ๋ณ„๋„๋กœ ์ถœ๋ ฅํ•˜๋„๋ก ํ”„๋กœ๊ทธ๋žจ ์ƒ์„ฑ

# calculationPurchase ํŒŒ์ผ

g1Price = 1200; g2Price = 1000; g3Price = 800;
g4Price = 2000; g5Price = 900


class invalidLiteralError(Exception):

    def __init__(self,str):
        super().__init__(f'invalid literal for int() with base 10 : {str}')

def calculator(*gcs):

    gcdDic = {}
    againCntInput = {}

    for idx, gc in enumerate(gcs):
        try:
            gcdDic[f'g{idx+1}'] = int(gc)
        except Exception as e:
            againCntInput[f'g{idx+1}'] = gc
            print(e)

    totalPrice = 0
    for g in gcdDic.keys():
        totalPrice += gcdDic[g] * globals()[f'{g}Price'] # โ˜…โ˜…โ˜…โ˜…โ˜… globals() : ์ „์—ญ๋ณ€์ˆ˜ ๋ฐ˜ํ™˜

    print('-'*30)
    print(f'์ด ๊ตฌ๋งค ๊ธˆ์•ก : {format(totalPrice,",")} ์›')
    print('-' * 10,'๋ฏธ๊ฒฐ์ œ ํ•ญ๋ชฉ','-'*10)
    for g in againCntInput.keys():
        print(f'์ƒํ’ˆ : {g}\t\t ๊ตฌ๋งค ๊ฐœ์ˆ˜ : {againCntInput[g]}')
    print('-' * 30)
# ์ƒํ’ˆ ๊ตฌ๋งค์— ๋”ฐ๋ฅธ โ€˜์ด ๊ตฌ๋งค ๊ธˆ์•กโ€™์„ ์ถœ๋ ฅํ•˜๋˜, ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ฐœ์ˆ˜๊ฐ€ ์ž˜ ๋ชป ์ž…๋ ฅ๋œ ๊ฒฝ์šฐ
# ๋ณ„๋„๋กœ ์ถœ๋ ฅํ•˜๋„๋ก ํ”„๋กœ๊ทธ๋žจ ์ƒ์„ฑ

import calculationPurchase as  cp

g1Cnt = input('good1 ๊ตฌ๋งค ๊ฐœ์ˆ˜ : ')
g2Cnt = input('good1 ๊ตฌ๋งค ๊ฐœ์ˆ˜ : ')
g3Cnt = input('good1 ๊ตฌ๋งค ๊ฐœ์ˆ˜ : ')
g4Cnt = input('good1 ๊ตฌ๋งค ๊ฐœ์ˆ˜ : ')
g5Cnt = input('good1 ๊ตฌ๋งค ๊ฐœ์ˆ˜ : ')

cp.calculator(g1Cnt,g2Cnt,g3Cnt,g4Cnt,g5Cnt)

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ์˜ˆ์™ธ์ฒ˜๋ฆฌ 04

๐Ÿ’ก ์ƒํ’ˆ ๊ตฌ๋งค์— ๋”ฐ๋ฅธ โ€˜์ด ๊ตฌ๋งค ๊ธˆ์•กโ€™์„ ์ถœ๋ ฅํ•˜๋˜, ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ฐœ์ˆ˜๊ฐ€ ์ž˜ ๋ชป ์ž…๋ ฅ๋œ ๊ฒฝ์šฐ ๋ณ„๋„๋กœ ์ถœ๋ ฅํ•˜๋„๋ก ํ”„๋กœ๊ทธ๋žจ ์ƒ์„ฑ

# mem ํŒŒ์ผ

class emptyDataException(Exception):
    def __init__(self,i):
        super().__init__(f'{i} is empty!')
def checkInputData(n,m,p,a,ph):

    if n == '':
        raise emptyDataException('name')
    if m == '':
        raise emptyDataException('mail')
    if p == '':
        raise emptyDataException('password')
    if a == '':
        raise emptyDataException('address')
    if ph == '':
        raise emptyDataException('phone')

class RegistMember():

    def __init__(self,n,m,p,a,ph):
        self.m_name = n
        self.m_email = m
        self.m_pw = p
        self.m_addr = a
        self.m_phone = ph
        print('Membership completed!')

    def printMemberInfo(self):
        print(f'm_name : {self.m_name}')
        print(f'm_email : {self.m_email}')
        print(f'm_pw : {self.m_pw}')
        print(f'm_addr : {self.m_addr}')
        print(f'm_phone : {self.m_phone}')
# ์ƒํ’ˆ ๊ตฌ๋งค์— ๋”ฐ๋ฅธ โ€˜์ด ๊ตฌ๋งค ๊ธˆ์•กโ€™์„ ์ถœ๋ ฅํ•˜๋˜, ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๊ฐœ์ˆ˜๊ฐ€ ์ž˜ ๋ชป ์ž…๋ ฅ๋œ ๊ฒฝ์šฐ ๋ณ„๋„๋กœ ์ถœ๋ ฅํ•˜๋„๋ก ํ”„๋กœ๊ทธ๋žจ ์ƒ์„ฑ

import mem

m_name = input('์ด๋ฆ„ ์ž…๋ ฅ :')
m_mail = input('๋ฉ”์ผ ์ฃผ์†Œ ์ž…๋ ฅ : ')
m_pw = input('๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅ : ')
m_address = input('์ฃผ์†Œ ์ž…๋ ฅ : ')
m_phone = input('์—ฐ๋ฝ์ฒ˜ ์ž…๋ ฅ : ')

try:
    mem.checkInputData(m_name,m_mail,m_pw,m_address,m_phone)
    newMember = mem.RegistMember(m_name,m_mail,m_pw,m_address,m_phone)
    newMember.printMemberInfo()
except mem.emptyDataException as e:
    print(e)

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ์˜ˆ์™ธ์ฒ˜๋ฆฌ 05

๋‹ค์Œ๊ณผ ๊ฐ™์€ ์€ํ–‰ ๊ณ„์ขŒ ๊ณ„์„ค ๋ฐ ์ž…/์ถœ๊ธˆ ํ”„๋กœ๊ทธ๋žจ์„ ์ƒ์„ฑ

# bank ํŒŒ์ผ

import random

class PrivateBank:

    def __init__(self,bank,account_name):
        self.bank = bank
        self.account_name = account_name


        while True:
            newAccount = random.randint(10000,99999)
            if bank.isAccount(newAccount) :
                continue
            else:
                self.account_no = newAccount
                break
        self.totalMoney = 0
        bank.addAccount(self)

    def printBankInfo(self):
        print('-'*40)
        print(f'account_name : {self.account_name}')
        print(f'account_no : {self.account_no}')
        print(f'totalMoney : {self.totalMoney}')



class Bank:
    def __init__(self):
        self.accounts = {}

    def addAccount(self,privateBank):
        self.accounts[privateBank.account_no] = privateBank

    def isAccount(self,account_no):
        return account_no in self.accounts

    def doDeposit(self,account_no, m):
        pb = self.accounts[account_no]
        pb.totalMoney = pb.totalMoney + m

    def doWithdraw(self, account_no, m):
        pb = self.accounts[account_no]
        if pb.totalMoney - m < 0:
            raise LackException(pb.totalMoney, m)
        pb.totalMoney = pb.totalMoney - m

class LackException(Exception):
    def __init__(self, m1, m2):
        super().__init__(f'์ž”๊ณ  ๋ถ€์กฑ!!, ์ž”์•ก : {m1}, ์ถœ๊ธˆ์•ก : {m2}')
# ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์€ํ–‰ ๊ณ„์ขŒ ๊ณ„์„ค ๋ฐ ์ž…/์ถœ๊ธˆ ํ”„๋กœ๊ทธ๋žจ์„ ์ƒ์„ฑ

import bank

koreaBank = bank.Bank()

name_account_name = input('ํ†ต์žฅ ๊ณ„์„ค์„ ์œ„ํ•œ ์˜ˆ๊ธˆ์ฃผ ์ž…๋ ฅ : ')
myAccount = bank.PrivateBank(koreaBank,name_account_name)
myAccount.printBankInfo()

while True:
    selectNumber = int(input('1. ์ž…๊ธˆ, \t2. ์ถœ๊ธˆ, \t3. ์ข…๋ฃŒ : '))

    if selectNumber == 1:
        money = int(input('์ž…๊ธˆ์•ก ์ž…๋ ฅ : '))
        koreaBank.doDeposit(myAccount.account_no, money)
        myAccount.printBankInfo()

    elif selectNumber == 2:
        money = int(input('์ถœ๊ธˆ์•ก ์ž…๋ ฅ : '))
        try:
            koreaBank.doWithdraw(myAccount.account_no, money)
            # myAccount.printBankInfo()
        except bank.LackException as e:
            print(e)
        finally:
            myAccount.printBankInfo()
    elif selectNumber == 3:
        print('bye~')
        break
    else:
        print('์ž˜๋ชป ์ž…๋ ฅํ–ˆ์Šต๋‹ˆ๋‹ค. ๋‹ค์‹œ ์„ ํƒํ•˜์„ธ์š”.')

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ํ…์ŠคํŠธ ํŒŒ์ผ 01

๐Ÿ’ก ํšŒ์› ๊ณ„์ •๋ณ„ ํ…์ŠคํŠธ ํŒŒ์ผ์„ ์ƒ์„ฑํ•œ ํ›„ ํšŒ์› ๋ณธ์ธ ํŒŒ์ผ์— โ€˜ํ•œ ์ค„ ์ผ๊ธฐโ€™๋ฅผ ์“ฐ๊ณ  ์ฝ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ƒ์„ฑ

# diary ํŒŒ์ผ

import time


def writeDiary(u,f,d):
    lt = time.localtime()
    timeStr = time.strftime('%Y-%m-%d %I:%M:%S %p',lt)

    filePath = u + f
    with open(filePath, 'a') as f:
        f.write(f'[{timeStr}] : {d}\n')

def readDiary(u,f):
    filePath = u + f
    dates = []
    with open(filePath,'r') as f:
        dates = f.readlines()
    return dates
# ํšŒ์› ๊ณ„์ •๋ณ„ ํ…์ŠคํŠธ ํŒŒ์ผ์„ ์ƒ์„ฑํ•œ ํ›„ ํšŒ์› ๋ณธ์ธ ํŒŒ์ผ์— โ€˜ํ•œ ์ค„ ์ผ๊ธฐโ€™๋ฅผ ์“ฐ๊ณ  ์ฝ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ƒ์„ฑ
import diary

members = {}
url = 'C:/Users/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/' # ๊ฒฝ๋กœ ์ˆ˜์ • ํ•„์š”

def printMembers():
    for member in members.keys():
        print(f'ID : {member}\t PW : {members[member]}')

while True:
    selectNum = int(input('1. ํšŒ์›๊ฐ€์ž…, 2. ํ•œ์ค„์ผ๊ธฐ์“ฐ๊ธฐ, 3. ์ผ๊ธฐ๋ณด๊ธฐ, 4. ์ข…๋ฃŒ'))

    if selectNum == 1:
        mId = input('input ID : ')
        mPw = input('input PW : ')
        members[mId] = mPw
        printMembers()
    elif selectNum == 2:
        mId = input('input Id : ')
        mPw = input('input PW : ')

        if mId in members and members[mId] == mPw: # โ˜…โ˜…โ˜…โ˜…โ˜…
            print('login success!!')
            fileName = 'myDiary_' + mId + '.txt'
            data = input('์˜ค๋Š˜ ํ•˜๋ฃจ ์ธ์ƒ ๊นŠ์€ ์ผ์„ ๊ธฐ๋กํ•˜์„ธ์š” : ')
            diary.writeDiary(url,fileName,data)
        else:
            print('login fail!')
            printMembers()
    elif selectNum == 3:
        mId = input('input ID : ')
        mPw = input('input PW : ')

        if mId in members and members[mId] == mPw:
            print('login success!!')
            fileName = 'myDiary_' + mId + '.txt'
            datas = diary.readDiary(url,fileName)
            for d in datas:
                print(d,end='')
        else:
            print('login fail!')
            printMembers()
    elif selectNum == 4:
        print('bye~')
        break

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ํ…์ŠคํŠธ ํŒŒ์ผ 02

ํ…์ŠคํŠธ ํŒŒ์ผ์— ์ˆ˜์ž…๊ณผ ์ง€์ถœ์„ ๊ธฐ๋กํ•˜๋Š” ๊ฐ€๊ณ„๋ถ€ ์ƒ์„ฑ

import time

def getTime():
    lt = time.localtime()
    st = time.strftime('%Y-%m-%d %H:%M:%S',lt)
    return st



while True:

    selectNumber = int(input('1. ์ž…๊ธˆ, \t2. ์ถœ๊ธˆ, \t3. ์ข…๋ฃŒ : '))

    if selectNumber == 1:
        money = int(input('์ž…๊ธˆ์•ก ์ž…๋ ฅ : '))
        with open('C:/Users/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/bank/money.txt','r') as f: # ๊ฒฝ๋กœ์ˆ˜์ • ํ•„์š”
            m = f.read()
        with open('C:/Users/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/bank/money.txt','w') as f: #๋ฎ์–ด์“ฐ๊ธฐ # ๊ฒฝ๋กœ์ˆ˜์ • ํ•„์š”
            f.write(str(int(m)+ money))

        memo = input('์ž…๊ธˆ ๋‚ด์—ญ ์ž…๋ ฅ : ')
        with open('C:/Users/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/bank/poketMoneyRegister.txt','a') as f: # ๊ฒฝ๋กœ์ˆ˜์ • ํ•„์š”
            f.write('-------------------\n')
            f.write(f'{getTime() }\n')
            f.write(f'[์ž…๊ธˆ] {memo} : {str(money)}์› \n')
            f.write(f'[์ž”์•ก] : {str(int(m) + money)}์› \n')

        print('์ž…๊ธˆ ์™„๋ฃŒ!')
        print(f'๊ธฐ์กด ์ž”์•ก : {m}')
        print(f'์ž…๊ธˆ ํ›„ ์ž”์•ก : {int(m) + money}')


    elif selectNumber == 2:
        money = int(input('์ถœ๊ธˆ์•ก ์ž…๋ ฅ : '))
        with open('C:/Users/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/bank/money.txt', 'r') as f: # ๊ฒฝ๋กœ ์ˆ˜์ • ํ•„์š”
            m = f.read()
        with open('C:/Users/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/bank/money.txt', 'w') as f:  # ๋ฎ์–ด์“ฐ๊ธฐ # ๊ฒฝ๋กœ ์ˆ˜์ • ํ•„์š”
            f.write(str(int(m) - money))

        memo = input('์ถœ๊ธˆ ๋‚ด์—ญ ์ž…๋ ฅ : ')
        with open('C:/Users/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/bank/poketMoneyRegister.txt', 'a') as f: # ๊ฒฝ๋กœ ์ˆ˜์ • ํ•„์š”
            f.write('-------------------\n')
            f.write(f'{getTime()}\n')
            f.write(f'[์ถœ๊ธˆ] {memo} : {str(money)}์› \n')
            f.write(f'[์ž”์•ก] : {str(int(m) - money)}์› \n')

        print('์ถœ๊ธˆ ์™„๋ฃŒ!')
        print(f'๊ธฐ์กด ์ž”์•ก : {m}')
        print(f'์ถœ๊ธˆ ํ›„ ์ž”์•ก : {int(m) - money}')


    elif selectNumber == 3:
        print('bye~')
        break
    else:
        print('๋‹ค์‹œ ์ž…๋ ฅํ•˜์„ธ์š”!')

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ํ…์ŠคํŠธ ํŒŒ์ผ 03

๐Ÿ’ก ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์ˆซ์ž์˜ ์•ฝ์ˆ˜๋ฅผ ํ…์ŠคํŠธ ํŒŒ์ผ์— ๊ธฐ๋ก

# ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์ˆซ์ž์˜ ์•ฝ์ˆ˜๋ฅผ ํ…์ŠคํŠธ ํŒŒ์ผ์— ๊ธฐ๋ก

# def divisor(num):
#     list = []
#     for n in range(1, num+1):
#         if num % n == 0:
#             list.append(n)
#     return list
#
#
# number = int(input('0๋ณด๋‹ค ํฐ ์ •์ˆ˜ ์ž…๋ ฅ : '))
#
# if number > 0:
#     divList = divisor(number)
#     with open('C:/Users/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/divisor.txt','a') as f: #๊ฒฝ๋กœ ์ˆ˜์ • ํ•„์š”
#         f.write(f'{number}์˜ ์•ฝ์ˆ˜ : {divList} \n')
#     print('divisor write complete!')
#
# else:
#     print('0๋ณด๋‹ค ํฐ ์ •์ˆ˜๋ฅผ ๋‹ค์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”')


inputNumber = int(input('0๋ณด๋‹ค ํฐ ์ •์ˆ˜ ์ž…๋ ฅ : '))

divisor = []
for number in range(1, (inputNumber + 1)):
    if inputNumber % number == 0:
        divisor.append(number)

if len(divisor) > 0:
    try:
        with open('C:/Users/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/divisor2.txt', 'a') as f: #๊ฒฝ๋กœ ์ˆ˜์ • ํ•„์š”
            f.write(f'{inputNumber}์˜ ์•ฝ์ˆ˜ : {divisor}\n')

    except Exception as e:
        print(e)
    else:
        print('divisor write complete!')

๐Ÿ’ก ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์ˆซ์ž๊นŒ์ง€์˜ ์†Œ์ˆ˜๋ฅผ ํ…์ŠคํŠธ ํŒŒ์ผ์— ๊ธฐ๋ก

# ์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•œ ์ˆซ์ž๊นŒ์ง€์˜ ์†Œ์ˆ˜๋ฅผ ํ…์ŠคํŠธ ํŒŒ์ผ์— ๊ธฐ๋ก

# def primeNumber(num):
#     list = []
#     for n in range(2,num+1):
#         flag = True
#         for i in range(2, n):
#             if n % i == 0:
#                 flag = False
#                 break
#         if flag :
#             list.append(n)
#     return list
#
# number = int(input('0๋ณด๋‹ค ํฐ ์ •์ˆ˜ ์ž…๋ ฅ : '))
#
# if number > 0:
#     primeList = primeNumber(number)
#     with open('C:/Users/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/primeNumber.txt','a') as f: #๊ฒฝ๋กœ ์ˆ˜์ • ํ•„์š”
#         f.write(f'{number}์˜ ์†Œ์ˆ˜ : {primeList} \n')
#         print('prime write complete!')
# else :
#     print('0๋ณด๋‹ค ํฐ ์ •์ˆ˜๋ฅผ ๋‹ค์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”')


inputNumber = int(input('0๋ณด๋‹ค ํฐ ์ •์ˆ˜ ์ž…๋ ฅ : '))
prime = []
for number in range(2, inputNumber + 1):
    flag = True
    for n in range(2,number):
        if number % n == 0:
            flag = False
            break
    if flag:
        prime.append(number)

if len(prime) > 0:
    try:
        with open('C:/Users/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/prime2.txt', 'a') as f: #๊ฒฝ๋กœ ์ˆ˜์ • ํ•„์š”
            f.write(f'{inputNumber}์˜ ์†Œ์ˆ˜ : {prime}\n')
    except Exception as e:
        print(e)
    else:
        print('prime write complete!')

[์—ฐ์Šต๋ฌธ์ œ] ํ…์ŠคํŠธ ํŒŒ์ผ 04

๋‘ ๊ฐœ์˜ ์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๊ณต์•ฝ์ˆ˜๋ฅผ ํ…์ŠคํŠธ ํŒŒ์ผ์— ์ž‘์„ฑ

# ๋‘ ๊ฐœ์˜ ์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๊ณต์•ฝ์ˆ˜๋ฅผ ํ…์ŠคํŠธ ํŒŒ์ผ์— ์ž‘์„ฑ

# inputNumber1 = int(input('1๋ณด๋‹ค ํฐ ์ •์ˆ˜ ์ž…๋ ฅ : '))
# inputNumber2 = int(input('1๋ณด๋‹ค ํฐ ์ •์ˆ˜ ์ž…๋ ฅ : '))
#
# commonDivisor = []
#
#
# if inputNumber1 == inputNumber2:
#     print(' ๊ฐ’์„ ๋‹ค์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”')
# elif inputNumber1 < inputNumber2:
#     for num in range(1, inputNumber1):
#         if inputNumber1 % num == 0 and inputNumber2 % num == 0:
#             commonDivisor.append(num)
# else:
#     for num in range(1, inputNumber2):
#         if inputNumber1 % num == 0 and inputNumber2 % num == 0:
#             commonDivisor.append(num)
#
# if len(commonDivisor) > 0:
#     try:
#         with open('C:/Users/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/commonDivisor.txt','a') as f: # ๊ฒฝ๋กœ ์ˆ˜์ • ํ•„์š”
#             f.write(f'{inputNumber1}์™€ {inputNumber2}์˜ ๊ณต์•ฝ์ˆ˜ : {commonDivisor} \n')
#     except Exception as e:
#         print(e)
#     else:
#         print('common factor write complete!')



inputNumber1 = int(input('1๋ณด๋‹ค ํฐ ์ •์ˆ˜ ์ž…๋ ฅ : '))
inputNumber2 = int(input('1๋ณด๋‹ค ํฐ ์ •์ˆ˜ ์ž…๋ ฅ : '))

common = []
for i in range(1, (inputNumber1) + 1):
    if inputNumber1 % i == 0 and inputNumber2 % i == 0:
        common.append(i)

if len(common) > 0:
    try:
        with open('C:/Users/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/commonDivisor2.txt','a') as f: # ๊ฒฝ๋กœ ์ˆ˜์ • ํ•„์š”
             f.write(f'{inputNumber1}์™€ {inputNumber2}์˜ ๊ณต์•ฝ์ˆ˜ : ')
            f.write(f'{common} \n')
    except Exception as e:
        print(e)
    else:
        print('common factor write complete!')

๋‘ ๊ฐœ์˜ ์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜๋ฅผ ํ…์ŠคํŠธ ํŒŒ์ผ์— ์ž‘์„ฑ

# ๋‘ ๊ฐœ์˜ ์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ์ตœ๋Œ€๊ณต์•ฝ์ˆ˜๋ฅผ ํ…์ŠคํŠธ ํŒŒ์ผ์— ์ž‘์„ฑ

# inputNumber1 = int(input('1๋ณด๋‹ค ํฐ ์ •์ˆ˜ ์ž…๋ ฅ : '))
# inputNumber2 = int(input('1๋ณด๋‹ค ํฐ ์ •์ˆ˜ ์ž…๋ ฅ : '))
#
# commonDivisor = ''
#
#
# if inputNumber1 == inputNumber2:
#     print(' ๊ฐ’์„ ๋‹ค์‹œ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”')
# elif inputNumber1 < inputNumber2:
#     for num in range(1, inputNumber1):
#         if inputNumber1 % num == 0 and inputNumber2 % num == 0:
#             commonDivisor = num
# else:
#     for num in range(1, inputNumber2):
#         if inputNumber1 % num == 0 and inputNumber2 % num == 0:
#             commonDivisor = num
#
# if commonDivisor != '':
#     try:
#         with open('C:/Users/์ดํƒœ์™„/Desktop/์ œ๋กœ๋ฒ ์ด์Šค/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/greatestCommonDivisor.txt','a') as f:
#             f.write(f'{inputNumber1}์™€ {inputNumber2}์˜ ๊ณต์•ฝ์ˆ˜ : {commonDivisor} \n')
#     except Exception as e:
#         print(e)
#     else:
#         print('common factor write complete!')


inputNumber1 = int(input('1๋ณด๋‹ค ํฐ ์ •์ˆ˜ ์ž…๋ ฅ : '))
inputNumber2 = int(input('1๋ณด๋‹ค ํฐ ์ •์ˆ˜ ์ž…๋ ฅ : '))

maxComNum = 0
for i in range(1, (inputNumber1) + 1):
    if inputNumber1 % i == 0 and inputNumber2 % i == 0:
        maxComNum = i


try:
    with open('C:/Users/์ดํƒœ์™„/Desktop/์ œ๋กœ๋ฒ ์ด์Šค/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/maxComNum2.txt','a') as f:
        f.write(f'{inputNumber1}์™€ {inputNumber2}์˜ ๊ณต์•ฝ์ˆ˜ : ')
        f.write(f'{maxComNum} \n')
except Exception as e:
    print(e)
else:
    print('common factor write complete!')

๐Ÿ’ก [์—ฐ์Šต๋ฌธ์ œ] ํ…์ŠคํŠธ ํŒŒ์ผ 05

  • datetime() : ๋‚ ์งœ ํ‘œ๊ธฐ (import datetime from datetime)
  • timedelta() : ์‹œ๊ฐ„์„ ๋”ํ•˜๊ฑฐ๋‚˜ ๋บ„ ์ˆ˜ ์žˆ๋‹ค(?) (import datetime from timedelta)

๐Ÿ’ก ์„ฌ๋งˆ์„์— ๊ณผ์ผ, ์ƒ์„ , ์•ผ์ฑ„๋ฅผ ํŒ๋งคํ•˜๋Š” ๋ฐฐ๊ฐ€ ๋‹ค์Œ ์ฃผ๊ธฐ๋กœ ์ž…ํ•ญํ•œ๋‹ค๊ณ  ํ•  ๋•Œ, ๋ชจ๋“  ๋ฐฐ๊ฐ€ ์ž…ํ•ญํ•˜๋Š” ๋‚ ์งœ๋ฅผ ํ…์ŠคํŠธ ํŒŒ์ผ์— ๊ธฐ๋ก (์ฒซ ์ž…ํ•ญ์ผ์€ 2021๋…„ 1์›” 1์ผ ์˜ค์ „ 10์‹œ๋กœ ํ•œ๋‹ค.)

#  ์„ฌ๋งˆ์„์— ๊ณผ์ผ, ์ƒ์„ , ์•ผ์ฑ„๋ฅผ ํŒ๋งคํ•˜๋Š” ๋ฐฐ๊ฐ€ ๋‹ค์Œ ์ฃผ๊ธฐ๋กœ ์ž…ํ•ญํ•œ๋‹ค๊ณ  ํ•  ๋•Œ,
# ๋ชจ๋“  ๋ฐฐ๊ฐ€ ์ž…ํ•ญํ•˜๋Š” ๋‚ ์งœ๋ฅผ ํ…์ŠคํŠธ ํŒŒ์ผ์— ๊ธฐ๋กํ•ด๋ณด์ž.
# (์ฒซ ์ž…ํ•ญ์ผ์€ 2021๋…„ 1์›” 1์ผ ์˜ค์ „ 10์‹œ๋กœ ํ•œ๋‹ค.

import time

ship1 = 3
ship2 = 4
ship3 = 5
maxDay = 0

for i in range(1, (ship1 + 1)):
    if ship1 % i == 0 and ship2 % i == 0:
        maxDay = i # ์ตœ๋Œ€ ๊ณต์•ฝ์ˆ˜

minDay = (ship1 * ship2) // maxDay  # ์ตœ์†Œ ๊ณต๋ฐฐ์ˆ˜

newDay = minDay
for i in range(1, (newDay + 1)):
    if newDay % i == 0 and ship3 % i == 0:
        maxDay = i

minDay = (newDay * ship3) // maxDay

print(f'minDay : {minDay}')
print(f'maxDay : {maxDay}')

from datetime import datetime
from datetime import timedelta

n = 1
baseTime = datetime(2021,1,1,10,0,0) # datetime() : ๋‚ ์งœ ํ‘œ๊ธฐ โ˜… 

with open('C:/Users/์ดํƒœ์™„/Desktop/์ œ๋กœ๋ฒ ์ด์Šค/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/arrive.txt','a') as f:
    f.write(f'2021๋…„ ๋ชจ๋“  ์„ ๋ฐ• ์ž…ํ•ญ์ผ\n')
    f.write(f'{baseTime}\n')

nexTime = baseTime + timedelta(days=minDay) # timedelta() : ์‹œ๊ฐ„์„ ๋”ํ•˜๊ฑฐ๋‚˜ ๋บ„ ์ˆ˜ ์žˆ๋‹ค(?) โ˜… 
while True:
    with open('C:/Users/์ดํƒœ์™„/Desktop/์ œ๋กœ๋ฒ ์ด์Šค/ํŒŒ์ด์ฌ ์ค‘๊ธ‰ pythontxt/arrive.txt','a') as f:
        f.write(f'{nexTime}\n')

    nexTime = nexTime + timedelta(days=minDay)
    if nexTime.year > 2021:
        break

๐Ÿ’ป ์ถœ์ฒ˜ : ์ œ๋กœ๋ฒ ์ด์Šค ๋ฐ์ดํ„ฐ ์ทจ์—… ์Šค์ฟจ

profile
#๋ฐ์ดํ„ฐ๋ถ„์„ #ํผํฌ๋จผ์Šค๋งˆ์ผ€ํŒ… #๋ฐ์ดํ„ฐ #๋””์ง€ํ„ธ๋งˆ์ผ€ํŒ…

0๊ฐœ์˜ ๋Œ“๊ธ€