[JavaScript] array 배열
배열선언 const array = [273, 'String', true, function () { }, {}, [273, 103]] 이런식으로 [] 안에 선언 push push하면 맨 뒷부분에 추가 된다. 배열.push(요소) 인덱스를 지정해서 삽입하기 비어있는 값은 empty로 출력된다. splice 배열.splice(인덱스, 제거할 요소의 개수) indexOf 요소의 위치값 확인 const itemsB = ['사과', '배', '바나나'] const index = itemsB.indexOf('바나나') index itemsB.splice(index, 1) itemsB itemsB.indexOf('바나나') 바나나는 배열에 없으므로 -1을 출력한다. ◦배열의 특정 위치에 요소 추가 배열.splice(인..
2022. 12. 20.
[Python] 숫자처리 함수
절대값 출력 print(abs(-5)) print(abs(5)) 최대, 최소 출력 print(max(5, 12)) print(max(1, 5, 12, 8, 14)) print(min(5, 12)) print(min(5, 12, 8)) print(min(5, 12, 8, 4)) 반올림 print(round(3.14)) print(round(3.99)) 내림, 올림, 제곱근 math 라이브러리를 import 해주어야 사용 가능하다. from math import * print(floor(4.99)) #내림 print(ceil(4.99)) #올림 print(sqrt(16)) #제곱근
2022. 12. 17.