일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- date_format
- 프로젝트
- 파이썬 몫
- YOLOv5
- python
- Python3
- html
- where
- 단어 공부
- 파이썬
- SQL 고득점 Kit
- sql
- css
- 슬라이싱
- ORDER BY
- Django
- Join
- 프로그래머스
- 아이엠어바텐더
- 데이터
- 백준
- map
- 파이썬 슬라이싱
- Len
- 코딩테스트 연습
- 설계
- pcce 기출문제
- count
- GIT
- List Comprehension
- Today
- Total
목록★ (182)
nan + nan = 2nan

코드 입력 word = input() # 단어 길이가 짝수일 경우 if (len(word)%2)==0: # 중간 두 문자 중 첫째 문자 인덱스 (ex. abcd -> b) std = len(word) // 2 # 앞 문자열 (ab) start_ = word[0:std] # 뒤 문자열 (cd) end_ = word[std:] # 앞 문자열과 뒷 문자열의 역순이 일치하면 1, 아니면 0 if start_ == end_[::-1]: print(1) else: print(0) # 단어 길이가 홀수일 경우 else: # 중간 문자의 인덱스 (ex. abcde -> c) std = len(word) // 2 # 앞 문자열 (ab) start_ = word[0:std] # 뒤 문자열 (cd) end_ = word[s..

EOFError "End of File Error"의 약자로, 입력 소스(파일 또는 표준 입력 등)에서 더 이상 읽을 데이터가 없을 때 발생하는 파이썬 예외입니다. 사용자로부터 입력을 받을 때, 파일의 끝에 도달하거나 입력이 더 이상 없을 때 발생할 수 있습니다. 코드 입력 # 값이 얼마나 들어올지 모르니, while문 사용 while True: try: word = input() # 입력이 더이상 없다면 break if not word: break print(word) # 입력이 더이상 없다면 break except EOFError: break 출처 : 백준 Online Judge

코드 입력 # 제시된 숫자 (별 개수가 최대가 되는 라인) num = int(input()) # 총 라인 수 max_ = 2*num-1 # 별 개수 value = 1 # 총 라인수만큼 루프문 생성 for i in range(1, max_+1): # 총 라인 수와 별 개수가 다르다면 (공백이 포함된 라인일 경우) if max_ != value: # 공백 개수 생성 vacant = int((max_ - value) / 2) print(f"{' '*vacant}{'*'*value}") # 별 개수가 최대가 되는 라인 이전 줄일 경우 if num > i: value += 2 # 별 개수가 줄어드는 라인일 경우 else: value -= 2 else: # 별 개수가 최대인 라인(다음 라인부터 별을 2개씩 차감 조..

코드 입력 def print_(word): """ 단어의 첫 글자와 마지막 글자만 뽑는 함수 """ start = word[0] end = word[-1] return start + end cnt = int(input()) # 처음 주어진 횟수만큼 루프문 생성 for _ in range(cnt): start_end = print_(input()) print(start_end) 출처 : 백준 Online Judge

코드 입력 word = input() print(len(word)) 출처 : 백준 Online Judge

코드 입력 basket_cnt, action_cnt = map(int, input().split()) # 바구니 순서대로 리스트 생성 result = [i for i in range(1, basket_cnt+1)] for _ in range(action_cnt): start_idx, end_idx = map(int, input().split()) # 구간별로 슬라이싱하여 [::-1]로 역순 변경 result[start_idx-1:end_idx] = result[start_idx-1:end_idx][::-1] print(' '.join(map(str, result))) 출처 : 백준 Online Judge

코드 입력 basket_cnt, action_cnt = map(int, input().split()) # 바구니 번호대로 리스트 생성 result = [i for i in range(1, basket_cnt+1)] for _ in range(action_cnt): # 첫 바구니, 두번째 바구니 번호 first_basket, second_basket = map(int, input().split()) # 첫 공의 값과 두번째 공의 값 first_ball = result[first_basket-1] second_ball = result[second_basket-1] # 값을 서로 교환 result[first_basket-1] = second_ball result[second_basket-1] = first_b..

코드 입력 basket_cnt, action_cnt = map(int, input().split()) # 바구니 개수만큼 0을 원소로 갖는 리스트 생성 result = [0 for _ in range(basket_cnt)] # 공을 바꾸는 횟수만큼 루프문 생성 for _ in range(action_cnt): start, end, ball_num = map(int, input().split()) # 구간 길이만큼 리스트 생성 후 값 변경 result[start-1:end] = [ball_num]*(end-(start-1)) print(' '.join(map(str, result))) 출처 : 백준 Online Judge

코드 입력 num = int(input()) word = 'long ' # 4로 나눈 몫을 구함 cnt = num // 4 # 몫만큼 단어를 생성 print(word*cnt + 'int') 출처 : 백준 Online Judge