[Today I Learn]
- SQL codekata
- Python codekata
- 오늘 배운 세션
- 오늘 배운 미니세션
[SQL codekata]
- 문제 1.
1. 문제 링크: https://www.hackerrank.com/challenges/weather-observation-station-13/problem
2. 정답 코드
select round(sum(lat_n),4)
from station
where lat_n > 38.7880 and lat_n < 137.2345
- 문제 2.
1. 문제 링크: https://www.hackerrank.com/challenges/weather-observation-station-14/problem
2. 정답 코드
select round(max(lat_n),4)
from station
where lat_n < 137.2345
[Python codekata]
- 문제 1.
1. 문제 링크: https://school.programmers.co.kr/learn/courses/30/lessons/120811?language=python3
2. 정답 코드
def solution(array):
ind = int(len(array)/2)
array.sort()
return array[ind]
def solution(array):
return sorted(array)[len(array)//2]
def solution(array):
array.sort()
return array[len(array)//2]
- 문제 2.
1. 문제 링크: https://school.programmers.co.kr/learn/courses/30/lessons/120813
2. 정답 코드
def solution(n):
answer = [i for i in range(n+1) if i % 2 != 0]
return answer
def solution(n):
answer = [i for i in range(n+1) if i % 2]
return answer
- 1인지 0인지 조건을 달 때는 1인 조건을 추출하는 경우라면 '!= 0' 달지말고 깔끔하게 작성하기
def solution(n):
return list(range(1, n+1, 2))
- 문제 3.
1. 문제 링크: https://school.programmers.co.kr/learn/courses/30/lessons/120818
2. 정답 코드
def solution(price):
discount = 0
if price >= 500000:
discount = 20
elif price >= 300000:
discount = 10
elif price >= 100000:
discount = 5
return int(price * (100-discount) / 100)
def solution(price):
discount = {500000 : 0.8, 300000 : 0.9, 100000 : 0.95, 0 : 1}
for paid, discounted in discount.items():
if price >= paid:
return int(price * discounted)
def solution(price):
if price >= 500000:
price *= 0.8
elif price >= 300000:
price *= 0.9
elif price >= 100000:
price *= 0.95
return int(price)
def solution(price):
return int(price*0.8) if price>=500000 else int(price*0.9) if price>=300000 else int(price*0.95) if price>=100000 else int(price)
'[데이터분석] 부트캠프 TIL' 카테고리의 다른 글
| 20260305 TIL (0) | 2026.03.05 |
|---|---|
| 20260304 TIL (0) | 2026.03.04 |
| 20260220 TIL (0) | 2026.02.20 |
| 20260219 TIL (0) | 2026.02.19 |
| 20260216 TIL (0) | 2026.02.17 |