목록PYTHON (24)
개발하고 싶어요
In [1]: from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity="all" import warnings warnings.filterwarnings('ignore') if문¶ In [2]: x = 10 if x == 10: print('10입니다') 10입니다 if 조건문과 들여쓰기¶ In [3]: x = 10 if x == 10: print('x에 들어가있는 숫자는 ') # if문의 조건식을 만족할 때 출력 print('10입니다') # if문 상관없이 출력하는 문장 x에 들어가있는 숫자는 10입니다 중첩 if조건문 사용¶ In [15]: x = 15 if x >= 10: pri..
In [1]: from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity="all" import warnings warnings.filterwarnings('ignore') 딕셔너리 만들기¶ 딕셔너리 = {key1 : value1, key2 : value2, ..} In [2]: lux = {'health' : 490, 'mana' : 334, 'melee' : 550, 'armor' : 18.72} lux Out[2]: {'health': 490, 'mana': 334, 'melee': 550, 'armor': 18.72} 특정 key값에 해당하는 value 출력 In [3]: lux[..
In [1]: from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity="all" import warnings warnings.filterwarnings('ignore') 시퀀스 자료형 확인하기¶ 시퀀스 자료형¶ list, tuple, range, str을 주로 사용 특정 값이 있는지¶ 값 in 시퀀스 객체 값 not in 시퀀스 객체 In [3]: a = [0, 10, 20, 30] 10 in a 40 in a Out[3]: True Out[3]: False In [4]: a = [0, 10, 20, 30] 10 not in a 60 not in a Out[4]: False Out[4..
In [1]: from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity="all" import warnings warnings.filterwarnings('ignore') 리스트 만들기¶ lst = [값, 값, ..] 리스트에 저장된 값은 요소(element) 리스트는 문자열, 정수, 실수, 불, 리스트 증 모든 자료형을 저장 가능 리스트는 추가, 변경 삭제가 가능 In [2]: lst = [12, 20, 30] lst Out[2]: [12, 20, 30] In [3]: lst = [1, 'python', 4.5, True, [1, 2]] lst Out[3]: [1, 'python', ..