목록programming (25)
돌맹이

입, 출금 및 잔고 확인을 할 수 있는 간단한 프로그램을 만들어보자 public class HumanExam10 { public static void main(String[] args) { boolean run = true; int balance = 0; Scanner scanner = new Scanner(System.in); while(run) { System.out.println("-----------------------------"); System.out.println("1.예금 | 2.출금 | 3.잔고 | 4.종료"); System.out.println("-----------------------------"); System.out.println("선택 > "); int choice = sca..
o가 들어간 단어만 추출하여 새로운 list를 만들어보자 ## 일반 문법을 사용한 반복문 a = ['computer','apple','human','zoo','country'] result_list=[] for x in a: if "o" in x: result_list.append(x) print(result_list) ['computer', 'zoo', 'country'] ## Pythonic을 사용한 반복문 a = ['computer','apple','human','zoo','country'] result_list2 = [x for x in a if 'o' in x] print(result_list2) ['computer', 'zoo', 'country'] 두 코드의 결과값은 같다. Python에서 ..
list와 tuple은 파이썬의 자료형으로 array값을 나타낼 때 사용한다. 두 자료형은 구조와 쓰임새가 비슷하지만 차이점도 존재한다. 공통점 1. indexing과 slicing이 가능 2. 둘다 iterable(반복 가능)함 차이점 1. list는 수정 가능(mutable) 하지만 tuple은 수정 불가능(immutable)

단수를 입력하면 구구단을 출력하는 메서드를 만들어보자 public class gugudan { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int i; int index; System.out.print("숫자를 입력하세요: "); i = sc.nextInt(); for(index=1;index

Github를 이용해 다른 PC에서 동일한 가상환경 생성하는 방법 Github의 repository 주소를 복사 바탕화면의 Git Bash를 열고 $ git clone 위와같이 입력한다 바탕화면에 해당폴더(여기선 tempPython)이 생성된다 다시 해당폴더의 Git Bash를 열고 $ virtualenv venv $ source venv/Scripts/activate $ pip install -r requirements.txt 를 차례로 입력해주면 기존과 동일한 가상환경 생성 완료