본문 바로가기

전체 글

(38)
2025.01.14 카이군 생일 축하드립니다 SQL 시험 문제1. customer 테이블에서 10일 이상의 영화를 대여한 고객들의 first_name, last_name을 조회하시오.SELECT DISTINCT c.first_name, c.last_nameFROM sakila.customer cJOIN sakila.rental r ON c.customer_id = r.customer_idWHERE DATEDIFF(r.return_date, r.rental_date) >= 10;   파이썬 시험 문제5. 문자열 속 단어 수 세기목표: 사용자가 입력한 문자열에서 단어의 개수를 세는 프로그램을 작성게임 규칙사용자는 한 줄의 문자열을 입력합니다.프로그램은 그 문자열에서 공백을 기준으로 단어를 분리하고, 단어의 개수를 출력합니다.공백만 있는 문자열이나, 앞..
2025.01.13... In [2]:import numpy as nparr = np.array([[1,2,3],[4,5,6]])arr Out[2]:array([[1, 2, 3], [4, 5, 6]]) In [6]:arr+arr #벡터화 element-wise#요소별로 계산 Out[6]:array([[ 2, 4, 6], [ 8, 10, 12]]) In [5]:arr/arr Out[5]:array([[1., 1., 1.], [1., 1., 1.]]) In [8]:lst = [[1,2,3],[4,5,6]]lst+lst #리스트는 안됨 Out[8]:[[1, 2, 3], [4, 5, 6], [1, 2, 3], [4, 5, 6]] In [11]:lit = [[1,2,3],[4,5,6]]lit2 = li..
코딩테스트 03 삼각형의 완성조건 (1)선분 세 개로 삼각형을 만들기 위해서는 다음과 같은 조건을 만족해야 합니다.가장 긴 변의 길이는 다른 두 변의 길이의 합보다 작아야 합니다.삼각형의 세 변의 길이가 담긴 배열 sides이 매개변수로 주어집니다. 세 변으로 삼각형을 만들 수 있다면 1, 만들 수 없다면 2를 return하도록 solution 함수를 완성해주세요.제한사항sides의 원소는 자연수입니다.sides의 길이는 3입니다.1 ≤ sides의 원소 ≤ 1,000def solution(sides): sides.sort() #오름차순 배열 if sides[0]+sides[1]>sides[2]: return 1 else: return 2def solution(sides): ..
프로그래머스 코딩테스트 02 배열 원소의 길이def solution(strlist): answer=[] for str in strlist: answer.append(len(str)) return answerdef solution(strlist): return [len(str) for str in strlist]  제곱수 판별def solution(n): if (int(n**0.5)**2) == n: return 1 else: return 2  점의 위치 구하기def solution(dot): if dot[0]>0 and dot[1] >0: return 1 elif dot[0]0: return 2 elif dot[0]0 an..
2025.01.10 TGIF~ ¶ In [2]:#offset: 상대주소; 기준이 되는 주소가 얼마나 떨어져 있는지#Math Case문#Match문: 패턴 매칭을 통해 값을 비교하고 실행 코드를 선택하는데 사용#Case문: Match문 내에서 특정 패턴에 대한 처리를 정의하는데 사용 In [6]:def classify_number(n): math n: case 0: print("Zero") case 1 | 2 | 3: print("Small number") case 4 | 5 | 6 | 7 | 8 | 9: print("Big number") case_: print('Other number')    ..
프로그래머스 코딩테스트 01 몫 구하기def solution(num1, num2): if num1 and num2 100: print('0과 100사이의 정수값을 입력해주세요.') exit return num1//num2  두 수의 곱def solution(num1, num2): 0solution = lambda num1, num2 : num1 * num2  나머지 구하기def solution(num1, num2): if num1 and num2>0 or num1 and num2 solution = lambda num1, num2 : num1 % num2 두 수의 차def solution(num1:int, num2:int)->int: if -50000 숫자 비교하기def solut..
2025.01.07 화요일 꺅! 많이 자서 기분 조아요 use my_database;create table BTreeExample( id INT auto_increment primary key, -- 각 데이터의 고유 ID value INT NOT NULL, -- 데이터 값 INDEX (value) -- B-tree 인덱스 생성);-- 초기 값을 삽입insert into BTreeExample (value) values (10), (20);-- 값 삽입 (예, 30, 분할 발생)insert into BTreeExample (value) values (30);-- 값 삽입 (예, 40, 50, 추가 분할 발생)insert into BTreeExample (value) values (40), (50);-- 값 삽입 (ex. 25..
2025.01.06 월 요 일........... SQL은 구조화된 쿼리 언어이며, 데이터에 쿼리를 줘서 원하는 데이터를 불러오게 하는 것having은 그룹화하고 나서, where은 그룹화하기 전 서브쿼리: SQL문 안에 포함되어 있는 또 다른 SQLselect customer_id, first_name, last_name, (select count(rental_id) from sakila.rental where customer_id = c.customer_id) as rental_countfrom sakila.customer cwhere customer_id = 5;select c.customer_id, c.first_name, c.last_name, count(r.rental_id) as rental_countfrom sakila.cust..