전체 글
[python][basic] 파이썬 코딩 컨벤션 정리
코딩 컨벤션(coding convention)이란? 코딩 컨벤션은 코드를 작성할 때 코드를 읽고 협업하며 관리할 때 효율성을 증진시키기 위해서 어떤 일관된 코딩 스타일을 사전에 약속하는 것이다. 이러한 코딩 스타일 규약은 지키지 않아도 실행 결과에는 영향을 미치지 않는다. 단지 어떤 일관성이 있는 기준을 두어 통일하면 더 나은 품질의 코드를 작성하는데 그리고 협업할 때의 불편함을 줄이는 데에 도움이 되기 때문이다. 코딩 컨벤션은 함께 일하는 팀 단위마다 정하고 사용해도 되지만 일반적으로 같은 언어를 공유하는 공동체에서 제공하는 컨벤션 가이드가 존재한다. (파이썬의 경우 PEP 8) Python Enhance Proposal(PEP) PEP중에서도 PEP 8이 파이썬 언어의 컨벤션에 대한 제안서이다. ww..
[codesignal][python] 10. Sort by Height
codesignal.com Coding Tests and Assessments for Technical Hiring | CodeSignal Learn how you can go beyond resumes in technical hiring with a state-of-the-art assessment platform and advanced coding tests codesignal.com level : easy Question: Some people are standing in a row in a park. There are trees between them which cannot be moved. Your task is to rearrange the people by their heights in a ..
[python][basic] 파이썬 외장함수
pickle¶ 객체의 형태를 그대로 유지하면서 파일에 저장하고 불러올 수 있다 dump를 통해 데이터 객체 저장 load를 통해 불러오기 In [2]: import pickle f=open("pickle.txt","wb") data={1:'python',2:'java'} pickle.dump(data,f) f.close() In [3]: f=open("pickle.txt",'rb') data=pickle.load(f) print(data) {1: 'python', 2: 'java'} os¶ os module은 환경 변수나 디렉터리, 파일 등의 OS 자원을 제어할 수 있게 도와주는 모듈 os.environ (내 시스템의 환경 변수 값을 알고 싶을 때)¶ 시스템은 제각기 다른 환경변수 값을 갖는다 os.en..
[python][basic] PSL-sys module
sys module: python library 중 하나이다. python library: 전 세계 파이썬 사용자들이 만든 유용한 프로그램을 모아 놓은 것. 그 중에서도 sys 모듈은 자주 사용됨 PSL: python standard library 우리는 이를 파이썬 외장함수라고 부른다 sys 파이썬 인터프리터가 제공하는 변수와 함수를 직접 제어할 수 있는 방법을 제공하는 모듈 명령 행에서 인수 전달하기 -sys.args python명령어 뒤의 모든 것들이 공백을 기준으로 나뉘어서 sys.argv리스트의 요소가 된다 확인해보기 위한 예제는 아래와 같다 #argv_test.py import sys print(sys.argv) 같은 디렉토리에 명령 프롬프트 창에서 python argv_test.py you ..
[codesignal][python] 9. isLucky
codesignal.com Coding Tests and Assessments for Technical Hiring | CodeSignal Learn how you can go beyond resumes in technical hiring with a state-of-the-art assessment platform and advanced coding tests codesignal.com level : easy Question: Ticket numbers usually consist of an even number of digits. A ticket number is considered lucky if the sum of the first half of the digits is equal to the s..
[codesignal][python] 8. commonCharacterCount
codesignal.com Coding Tests and Assessments for Technical Hiring | CodeSignal Learn how you can go beyond resumes in technical hiring with a state-of-the-art assessment platform and advanced coding tests codesignal.com level : easy Question: Given two strings, find the number of common characters between them. 두 string이 주어지면 서로 같은 겹치는 요소의 개수를 반환하는 문제 Example: For s1 = "aabcc" and s2 = "adcaa", t..
[codesignal][python] 7. AllLongestStrings
codesignal.com Coding Tests and Assessments for Technical Hiring | CodeSignal Learn how you can go beyond resumes in technical hiring with a state-of-the-art assessment platform and advanced coding tests codesignal.com level : easy Question: Given an array of strings, return another array containing all of its longest strings. Example: For inputArray = ["aba", "aa", "ad", "vcd", "aba"], the outp..