본문 바로가기

전체 글820

Shortest Word Description: Simple, given a string of words, return the length of the shortest word(s). String will never be empty and you do not need to account for different data types. Solution: 1. Count the number of letters in each word. 2. Returns the smallest number of characters. def find_short(s): return min(list(map(len, s.split()))) 2022. 4. 23.
Vowel Count Description: Return the number (count) of vowels in the given string. We will consider a, e, i, o, u as vowels for this Kata (but not y). The input string will only consist of lower case letters and/or spaces. Solution: 1. Check whether the characters in the 'sentence' are included in 'aeiou'. 2. Returns the number of included characters. def get_count(sentence): return sum([i in 'aeiou' for i i.. 2022. 4. 22.
String ends with? Description: Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string). Examples: solution('abc', 'bc') # returns true solution('abc', 'd') # returns false Solution: 1. Return True if the last digit of 'string' is the same as 'ending'. 2. If 'ending' is an empty string, return True. 3. If not, return False. def solution(strin.. 2022. 4. 21.
SQLAlchemy를 이용해 csv파일 DB업로드 하는 방법(feat. psql) CSV 대량의 데이터를 디비에 업로드하기 위해 사용되는 것 중에 하나가 csv파일입니다. csv파일은 데이터들이 콤마로 구분되어진 파일을 뜻하는데 엑셀이나 스프레드 시트 등에서 쉽게 변환시켜 다운로드할 수 있습니다. 오늘은 실습으로 krx 한국거래소에서 제공하는 종목 데이터를 디비에 업로드해보겠습니다. 먼저 krx 한국거래소에서 받은 종목 데이터 파일은 다음과 같습니다. (csv로 다운받을 수 있습니다) # stock.csv 종목코드,종목명,시장구분,소속부,종가,대비,등락률,시가,고가,저가,거래량,거래대금,시가총액,상장주식수 60310,3S,KOSDAQ,중견기업부,3445,15,0.44,3450,3485,3430,61292,211021945,159405362285,46271513 95570,AJ네트웍스,.. 2022. 4. 21.
Remove the minimum Description: The museum of incredible dull things The museum of incredible dull things wants to get rid of some exhibitions. Miriam, the interior architect, comes up with a plan to remove the most boring exhibitions. She gives them a rating, and then removes the one with the lowest rating. However, just as she finished rating all exhibitions, she's off to an important fair, so she asks you to wr.. 2022. 4. 20.
pytest _ 하나의 함수에서 복수 케이스 테스트 하는 방법 단일 케이스 테스트 보통 테스트는 단일 케이스로 이루어집니다. 단일 케이스로 테스트를 하면 최소의 단위로 테스트를 진행하기 때문에 코드의 정확도를 높일 수 있고, 보는 이에게도 명확한 케이스 사례를 보여줄 수 있다는 장점이 있습니다. 예를 들어 회원가입 API를 테스트한다고 할 때 케이스를 다음처럼 나눌 수 있습니다. 성공 : 회원가입이 성공했는가? 실패1 : 회원가입 시 이메일이 중복되는가? 실패2 : 회원가입 시 닉네임이 중복되는가? 실패3 : 회원가입 시 패스워드가 유효한가? 하지만 유사한 케이스를 모두 단일 케이스로 테스트할 경우 비슷한 코드가 반복되면서 가독성과 효율이 떨어질 수 있습니다. 위의 케이스 중에서 실패1, 실패2를 살펴보겠습니다. 이 둘은 중복여부에 의한 실패를 확인하는 테스트로 엄.. 2022. 4. 20.