목록Python (5)
히바리 쿄야 와 함께 하는 Developer Cafe
def GuGu(n): result = [] result.append(n*1) result.append(n*2) result.append(n*3) result.append(n*4) result.append(n*5) result.append(n*6) result.append(n*7) result.append(n*8) result.append(n*9) return result print(GuGu(2)) [2, 4, 6, 8, 10, 12, 14, 16, 18] i = 1 while i < 10: print(i) i+=1 1 2 3 4 5 6 7 8 9 def GuGu(n): result = [] i = 1 while i < 10: result.append(n * i) i = i + 1 return resul..
D:\Python>mkdir mymod D:\Python>move mod2.py mymod 1개 파일을 이동했습니다. D:\Python>python Python 3.9.1 (tags/v3.9.1:1e5d33e, Dec 7 2020, 17:08:21) [MSC v.1927 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', 'C:\\Users\\SONG\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip', 'C:\\Users\\SONG\\AppData\\Local\\Progra..
함수를 먼저 정의해야 함 def add(a,b): return a + b add 라는 함수를 먼저 정의함 a = 3 b = 4 c = add(a, b) print(c) 7 print(add(3,4)) 7 def 함수이름(매개변수): 수행할 문장 ... return 결과값 a = add(3,4) print(a) 7 결과값을 받을 함수 = 함수이름(입력인수 1, 인력인수 2,...) def hello(): return 'hello' 헬로우라는 함수를 정의 a = hello() 헬로우 함수를 a 변수에 저장 print(a) a값을 호출 hello 결과값 나옴 결과값이 없는 함수를 호출하면 돌려주는 값이 없기 떄문에 add 함수를 사용 add(3,4) 함수이름(입력인수1, 입력인수2) Out[12]: 7 def..
콘솔창 실습 로그 내용 t1 = (1,2,'a','b') t1[0] Out[3]: 1 t1[3] Out[4]: 'b' t1 = (1,2,'a','b') t1[1:] Out[6]: (2, 'a', 'b') t2 = (3,4) t1 + t2 Out[8]: (1, 2, 'a', 'b', 3, 4) t2 = (3,4) t1 + t2 Out[10]: (1, 2, 'a', 'b', 3, 4) t2 * 3 Out[11]: (3, 4, 3, 4, 3, 4) t1 = (1,2,'a','b') len(t1) Out[13]: 4 a1 = (1,2,3) a1 + (4) Traceback (most recent call last): File "", line 1, in a1 + (4) TypeError: can only conc..
실습 IDE 스파이더 www.spyder-ide.org/ -> 다운로드 설치하면 됨 # -*- coding: utf-8 -*- """ Created on Fri Feb 5 15:12:26 2021 @author: SONG """ #hello.py print("hello world"); #multistring.py print("=" * 50) print("My Program") print("=" * 50) 콘솔창 로그 실습 a = "Life is too short, you need Python" a[0] Out[2]: 'L' a[12] Out[3]: 's' a[-1] Out[4]: 'n' b = a[0] + a[1] + a[2] + a[3] b Out[6]: 'Life' a[0:4] -> a의 0번째 배열..