SPARCS 파이썬 세미나 2010

Size: px
Start display at page:

Download "SPARCS 파이썬 세미나 2010"

Transcription

1 발로하는 파이썬세미나 1

2 강성훈 2

3 3

4 시작하기전에 : 4

5 왜? 5

6 C C++ 자바 6

7 C C++ 자바 파이썬? 7

8 스크립팅언어 8

9 빠르게짜고 빠르게확인하고 빠르게고친다 9

10 print "Hello, world!" 10

11 11

12 12

13 계산기 13

14 >>> * (5-6) -1 14

15 >>> 8/5 1 15

16 >>> 8/5 1 >>> 8%5 3 16

17 >>> 8.0 /

18 >>> 8.0 / >>> 8 /

19 5 5.0 (O) (X) 19

20 자료형 20

21 >>> "foo" + 'bar' 'foobar' 21

22 >>> "foo" * 4 'foofoofoofoo' 22

23 >>> == 2 True >>> == 3 False 23

24 참과거짓 : True, False 정수 : 1, 2, -3, -4, 실수 : 1.0, -2.34, 문자열 : 'x', "Hello", 기타등등 24

25 >>> ( ) *

26 내가니학점을 어찌아니? 26

27 >>> grade = 2.05 >>> (3.0 - grade) *

28 >>> grade = 2.05 >>> (3.0 - grade) * >>> grade = 2.89 >>> (3.0 - grade) *

29 변수 29

30 >>> grade = 3.5 >>> (3.0 - grade) *

31 >>> grade = 3.5 >>> if grade < 3.0: (3.0 - grade) * else:

32 >>> grade = 1.86 >>> if grade < 3.0: (3.0 - grade) * else:

33 >>> grade = 1.86 >>> if grade < 2.0: ( ) * elif grade < 3.0: (3.0 - grade) * else:

34 >>> grade = 1.86 >>> if grade < 3.0:... if grade < 2.0: ( ) * else: (3.0-grade) * else:

35 >>> for i in range(13):... print i+1,' 인의아해가거리를질주하오.'... 1 인의아해가거리를질주하오. 2 인의아해가거리를질주하오. ( 생략 ) 13 인의아해가거리를질주하오. 35

36 for i in range(1,101): one = (i%10==3 or i%10==6 or i%10==9) ten = (i/10==3 or i/10==6 or i/10==9) if one and ten: print ' 짝짝 ' elif one or ten: print ' 짝 ' else: print i 36

37 너무복잡하네 37

38 Refactoring? 38

39 # x 가 3, 6, 9 이면 True 아니면 False def is369(x): return x==3 or x==6 or x==9 39

40 def is369(x): return x==3 or x==6 or x==9 for i in range(1,101): one = is369(i%10) ten = is369(i/10) if one and ten: print ' 짝짝 ' elif one or ten: print ' 짝 ' else: print i 40

41 def is369(x): return x==2 or x==3 or x==5 or x==7 for i in range(1,101): one = is369(i%10) ten = is369(i/10) if one and ten: print ' 짝짝 ' elif one or ten: print ' 짝 ' else: print i 41

42 def needsclap(x): return x==2 or x==3 or x==5 or x==7 for i in range(1,101): one = needsclap(i%10) ten = needsclap(i/10) if one and ten: print ' 짝짝 ' elif one or ten: print ' 짝 ' else: print i 42

43 함수 단순히코드를묶는것이아닌 43

44 range 도함수인가요? 44

45 >>> range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 45

46 >>> [1, 2, 3] [1, 2, 3] >>> [4, 5] + ['hello?'] [4, 5, 'hello?'] >>> [41, 42] * 3 [41, 42, 41, 42, 41, 42] >>> [] [] 46

47 >>> (1, 2, 3) (1, 2, 3) >>> (4, 5) + ('hello?',) (4, 5, 'hello?') >>> (41, 42) * 3 (41, 42, 41, 42, 41, 42) >>> () () 47

48 >>> a = [1,2,3] >>> a[0] + a[1] + a[2] 6 >>> a[1] = 5 >>> a [1, 5, 3] 48

49 a a[0] a[-9] a[1] a[-8] a[2] a[-7] a[3] a[-6] a[4] a[-5] a[5] a[-4] a[6] a[-3] a[7] a[-2] a[8] a[-1] 49

50 >>> b = (1,2,3) >>> b[0] + b[1] + b[2] 6 >>> b[1] = 5 Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'tuple' object does not support item assignment 50

51 >>> b = (1,2,3) >>> b = b[:1] + (5,) + b[2:] >>> b (1, 5, 3) 51

52 a[3:8] a[0] a[-9] a[1] a[-8] a[2] a[-7] a[3] a[-6] a[4] a[-5] a[5] a[-4] a[6] a[-3] a[7] a[-2] a[8] a[-1] 52

53 a[-3:0:-2] a[0] a[-9] a[1] a[-8] a[2] a[-7] a[3] a[-6] a[4] a[-5] a[5] a[-4] a[6] a[-3] a[7] a[-2] a[8] a[-1] 53

54 사실이런거 몰라도돼요 54

55 a[::-1] a[0] a[-9] a[1] a[-8] a[2] a[-7] a[3] a[-6] a[4] a[-5] a[5] a[-4] a[6] a[-3] a[7] a[-2] a[8] a[-1] 55

56 56

57 리스트와튜플을 함께쓸이유 57

58 birthdays = [ (' 강성훈 ', 1987, 9, 13), (' 정재성 ', 1987, 2, 23), (' 김준기 ', 1987, 5, 12), ] 58

59 for entry in birthdays: name, year, month, day = entry print name, month, ' 월 ', day, ' 일생 ' 59

60 for name, year, month, day in birthdays: print name, month, ' 월 ', day, ' 일생 ' 60

61 for name, _, month, day in birthdays: print name, month, ' 월 ', day, ' 일생 ' 61

62 for name, _, month, day in birthdays: print '%s - %d 월 %d 일생 ' % \ (name, month, day) 62

63 for name, _, month, day in birthdays: print '{0} - {1} 월 {2} 일생 '.format( name, month, day) 63

64 메소드 64

65 자료형이나값과 연관된함수 65

66 formatfun = '{0} - {1} 월 {2} 일생 '.format for name, _, month, day in birthdays: print formatfunc(name, month, day) 66

67 자료형 = 값 67

68 >>> type(4) <type 'int'> >>> type('hello?') <type 'str'> >>> type([1,2,3]) <type 'list'> 68

69 >>> type(4) == int True >>> type('hello?') == str True >>> type([1,2,3]) == list True 69

70 >>> str.format <method 'format' of 'str' objects> 70

71 fmt = '{0} - {1} 월 {2} 일생 ' for name, _, month, day in birthdays: # 엄밀하게는 print str.format(fmt, name, month, day) 71

72 >>> 'hello'.upper() 'HELLO' >>> _.lower() 'hello' >>> ' '.join(['we','are','the','world']) 'we are the world' >>> _.split(' ') ['we', 'are', 'the', 'world'] 72

73 >>> len('hello') 5 >>> str(42) '42' >>> '%d' % 42 '42' 73

74 >>> print str(1/5.0) 0.2 >>> 1/ >>> print repr(1/5.0)

75 def names(birthdays): result = [] for name, _, _, _ in birthdays: result.append(name) result.sort() return result 75

76 >>> names(birthdays) ['\xb0\xad\xbc\xba\xc8\xc6', '\xb1\xe8\xc1\xd8\xb1\xe2', '\xc1\xa4\xc0\xe7\xbc\xba'] 76

77 >>> for name in names(birthdays):... print name... 강성훈김준기정재성 77

78 원래세상 다이런거지 78

79 def printbirthdays(birthdays): for name, _, month, day in birthdays: print '%s - %d월 %d일생' % \ (name, month, day) 79

80 def filterbyyear(birthdays, targetyear): result = [] for entry in birthdays: _, year, _, _ = entry if year == targetyear: result.append(entry) return result 80

81 def filterbyyear(birthdays, targetyear): def func(entry): _, year, _, _ = entry return year == targetyear return filter(func, birthdays) 81

82 def filterbyyear(birthdays, targetyear): def func((name, year, month, day)): return year == targetyear return filter(func, birthdays) 82

83 def filterbyyear(birthdays, targetyear): return filter( lambda (n,y,m,d): y==targetyear, birthdays) 83

84 def filterbyyear(birthdays, targetyear): return [(name, year, month, day) for name, year, month, day in birthdays if year == targetyear] 84

85 85

86 스크립팅언어? 86

87 스크립팅언어 87

88 스크립팅핛때쓰면 스크립팅언어 88

89 목표 89

90 생년월일검색하는 프로그램 90

91 보통은이름과생년월일을모두보여준다 이름만보여줄수도있다 이름으로검색핛수있다 생년별목록도볼수있다 91

92 birthdays = [ (' 강성훈 ', 1987, 9, 13), (' 정재성 ', 1987, 2, 23), (' 김준기 ', 1987, 5, 12), (' 안병욱 ', 1989, 10, 14), (' 강철 ', 1990, 3, 11), (' 유수형 ', 1991, 3, 13), (' 조유정 ', 1990, 4, 18), (' 김도국 ', 1990, 3, 11), ] 92

93 데이터는 data.py 프로그램은 birthday.py 93

94 출력핛때는 꼭 print 명령을 써야핚다 94

95 95

96 # coding=cp949 utf-8이어야할수도있음 birthdays = [ (' 강성훈 ', 1987, 9, 13), (' 정재성 ', 1987, 2, 23), (' 김준기 ', 1987, 5, 12), (' 안병욱 ', 1989, 10, 14), (' 강철 ', 1990, 3, 11), (' 유수형 ', 1991, 3, 13), (' 조유정 ', 1990, 4, 18), (' 김도국 ', 1990, 3, 11), ] 96

97 원래세상 다이런거지 (2) 97

98 >>> import data >>> print '%d 명 ' % len(data.birthdays) 8 명 98

99 # coding=cp949 import data print '%d 명 ' % len(data.birthdays) 99

100 # coding=cp949 from data import birthdays print '%d 명 ' % len(birthdays) 100

101 모듈 101

102 birthday.py main import data data.py data 102

103 persons.py main import birthday birthday.py birthday import data data.py data 103

104 # coding=cp949 from data import birthdays def main(): print '%d 명 ' % len(birthdays) if name == ' main ': main() 104

105 birthday.py main import data data.pyc data 105

106 def main(): choice = showmenu() if choice == 1: printnames(birthdays) elif choice == 2: printbirthdays(birthdays) elif choice == 3: printbyname(birthdays) elif choice == 4: printbyyear(birthdays) 106

107 def printnames(birthdays): pass # 이름만출력할것 def printbirthdays(birthdays): pass # 이름과생년월일을출력할것 def printbyname(birthdays): pass # 이름을입력받아서 # 해당하는생년월일을출력 def printbyyear(birthdays): pass # 생년을입력받아서 # 해당하는목록을출력 107

108 def printnames(birthdays): print 'TODO: 이름목록을출력 ' def printbirthdays(birthdays): print 'TODO: 이름과생년월일출력 ' def printbyname(birthdays): print ('TODO: 이름을입력받아 ' ' 해당하는생년월일을출력 ') def printbyyear(birthdays): print ('TODO: 생년을입력받아 ' ' 해당하는목록을출력 ') 108

109 def showmenu(): print '---- 메뉴 ----' print '1. 이름보기 ' print '2. 이름과생년월일보기 ' print '3. 이름으로찾기 ' print '4. 생년으로찾기 ' return input('>>> ') 109

110 ---- 메뉴 이름보기 2. 이름과생년월일보기 3. 이름으로찾기 4. 생년으로찾기 >>> 2 TODO: 이름과생년월일출력 110

111 ---- 메뉴 이름보기 2. 이름과생년월일보기 3. 이름으로찾기 4. 생년으로찾기 >>> 5 111

112 ---- 메뉴 이름보기 2. 이름과생년월일보기 3. 이름으로찾기 4. 생년으로찾기 >>> 3*4-11 TODO: 이름목록을출력 112

113 ---- 메뉴 이름보기 2. 이름과생년월일보기 3. 이름으로찾기 4. 생년으로찾기 >>> end Traceback (most recent call last): ( 생략 ) File "<string>", line 1, in <module> NameError: name 'end' is not defined 113

114 ---- 메뉴 이름보기 2. 이름과생년월일보기 3. 이름으로찾기 4. 생년으로찾기 >>> [ 엔터 ] Traceback (most recent call last): ( 생략 ) File "<string>", line 0 ^ SyntaxError: unexpected EOF while parsing 114

115 input 으로는 안된다 115

116 >>> dir() [' builtins ', ' doc ', ' name ', ' package '] >>> dir( builtins ) ['ArithmeticError', 'AssertionError', ( 생략 ), 'xrange', 'zip'] 116

117 >>> [x for x in dir( builtins )... if 'input' in x] ['input', 'raw_input'] 117

118 >>> help(raw_input) Help on built-in function raw_input in module builtin : raw_input(...) raw_input([prompt]) -> string Read a string from standard input. The trailing newline is stripped. If the user hits EOF (Unix: Ctl-D, Windows: Ctl-Z+Return), raise EOFError. On Unix, GNU readline is used if enabled. The prompt string, if given, is printed without a trailing newline before reading. 118

119 모르는게있으면 우선 help 를! 119

120 def inputnum(prompt): return input(prompt) def showmenu(): print '---- 메뉴 ----' print '1. 이름보기 ' print '2. 이름과생년월일보기 ' print '3. 이름으로찾기 ' print '4. 생년으로찾기 ' return inputnum('>>> ') 120

121 def inputnum(prompt): return int(raw_input(prompt)) 121

122 def inputnum(prompt): while True: # 무한반복 ( 사용에주의!) line = raw_input(prompt) try: return int(line) except: print ' 숫자를입력하시죠.' 122

123 예외 (exception) 일반적이지않다 123

124 >>> 3/0 Traceback (most recent call last): File "<stdin>", line 1, in <module> ZeroDivisionError: integer division or modulo by zero 124

125 >>> asdf Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'asdf' is not defined 125

126 >>> int('notanumber') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for int() with base 10: 'notanumber' 126

127 ---- 메뉴 이름보기 2. 이름과생년월일보기 3. 이름으로찾기 4. 생년으로찾기 >>> exit 숫자를입력하시죠. >>> quit 숫자를입력하시죠. >>> 나좀나가게해줘ㅆㅂ숫자를입력하시죠. 127

128 나가는메뉴가없다 Ctrl-C 같은강제종료키도 try~except 가먹어버린다 128

129 def showmenu(): print '---- 메뉴 ----' print '1. 이름보기 ' print '2. 이름과생년월일보기 ' print '3. 이름으로찾기 ' print '4. 생년으로찾기 ' print '0. 끝내기 ' return inputnum('>>> ') 129

130 def inputnum(prompt): while True: line = raw_input(prompt) try: return int(line) except ValueError: print ' 숫자를입력하시죠.' 130

131 방어적프로그래밍 131

132 def names(birthdays): result = [] for name, _, _, _ in birthdays: result.append(name) result.sort() return result def printnames(birthdays): print ', '.join(names(birthdays)) 132

133 def printbirthdays(birthdays): for name, _, month, day in birthdays: print '%s - %d월 %d일생' % \ (name, month, day) 133

134 def printbyname(birthdays): name = raw_input(' 이름을입력하세요 : ') for n, y, m, d in birthdays: if n == name: print '%s - %d월 %d일생' % \ (n, m, d) 134

135 def printbyname(birthdays): name = raw_input(' 이름을입력하세요 : ') count = 0 for n, y, m, d in birthdays: if n == name: print '%s - %d월 %d일생' % \ (n, m, d) count += 1 if count == 0: print ' 그런사람이없습니다.' 135

136 똑같은기능에 똑같은성능이면 갂결핚게낫다 136

137 def filterbyname(birthdays, targetname): return [(name, year, month, day) for name, year, month, day in birthdays if name == targetname] def printbyname(birthdays): name = raw_input(' 이름을입력하세요 : ') filtered = filterbyname(birthdays, name) printbirthdays(filtered) 137

138 def filterbyyear(birthdays, targetyear): return [(name, year, month, day) for name, year, month, day in birthdays if year == targetyear] def printbyyear(birthdays): year = inputnum(' 생년을입력하세요 : ') filtered = filterbyyear(birthdays, year) printbirthdays(filtered) 138

139 ---- 메뉴 이름보기 2. 이름과생년월일보기 3. 이름으로찾기 4. 생년으로찾기 0. 끝내기 >>> 4 생년을입력하세요 : 1990 강철 - 3월 11일생조유정 - 4월 18일생김도국 - 3월 11일생 139

140 새기능을만들려면? 140

141 def main(): choice = showmenu() if choice == 1: printnames(birthdays) elif choice == 2: printbirthdays(birthdays) def showmenu(): elif choice == 3: print '---- 메뉴 ----' printbyname(birthdays) print '1. 이름보기 ' elif choice == 4: print '2. 이름과생년월일보기 ' printbyyear(birthdays) print '3. 이름으로찾기 ' 여기다새메뉴를추가 print '4. 생년으로찾기 ' print '0. 끝내기 ' 여기다새조건을추가 return inputnum('>>> ') 141

142 하나의함수에 하나의기능을 142

143 def showmenu(): print '---- 메뉴 ----' print '1. 이름보기 ' print '2. 이름과생년월일보기 ' print '3. 이름으로찾기 ' print '4. 생년으로찾기 ' print '0. 끝내기 ' choice = inputnum('>>> ') if choice == 1: return printnames elif choice == 2: return printbirthdays elif choice == 3: return printbyname elif choice == 4: return printbyyear 143

144 CHOICES = {1: printnames, 2: printbirthdays, 3: printbyname, 4: printbyyear} def showmenu(): print '---- 메뉴 ----' print '1. 이름보기 ' print '2. 이름과생년월일보기 ' print '3. 이름으로찾기 ' print '4. 생년으로찾기 ' print '0. 끝내기 ' choice = inputnum('>>> ') if choice in CHOICES: return CHOICES[choice] 144

145 def main(): routine = showmenu() if routine: routine(birthdays) 145

146 def main(): while True: routine = showmenu() if not routine: return routine(birthdays) print 146

147 main: 시작함수 showmenu: 메뉴를보여줌 inputnum: 숫자를입력받음 names: 목록에서이름만반홖 filterby : 목록을조건에따라걸러냄 printbirthdays: 목록을출력 print : 각메뉴를구현함 147

148 여전히중복이 있지않나요? 148

149 for name,_,_,_ in birthdays: for name,_,month,day in birthdays: [(name,year,month,day) for name,year,month,day in birthdays if ] 149

150 순서를하나라도 삐끗핚다면? 150

151 새자료형을만들기 151

152 class person(object): def init (self, name, year, month, day): self.name = name self.year = year self.month = month self.day = day 152

153 자료형과연관된 함수? 153

154 즉그냥함수 ( 첫인자만빼고 ) 154

155 class person(object): def init (you, name, year, month, day): you.name = name you.year = year you.month = month you.day = day 155

156 >>> p = person(' 강성훈 ', 1987, 9, 13) >>> p < main.person object at 0x00B12110> >>> print p.name 강성훈 >>> p.year, p.month, p.day (1987, 9, 13) 156

157 class person(object): def init (self, name, year, month, day): self.name = name self.year = year self.month = month self.day = day def str (self): return '%s - %d월 %d일생' % \ (self.name, self.month, self.day) 157

158 >>> print str(p) < main.person object at 0x00B12110> 158

159 파이썬메모리의 구조 159

160 정수 1987 미지의세계 정수 9 미지의세계 정수 13 자료형 person 미지의세계 값 person ( 클래스 ) 미지의세계 문자열 ' 강성훈 ' 미지의세계 환경 name year month day person p 160

161 자료형 person 미지의세계자료형 person 미지의세계 값 person ( 클래스 ) name month year day 환경 person p 161

162 모든것은 요레퍼런스로 162

163 >>> a = [[]] * 3 >>> a [[], [], []] >>> a[0].append(4) >>> a [[4], [4], [4]] 163

164 >>> a = [[] for i in range(3)] >>> a [[], [], []] >>> a[0].append(4) >>> a[1].append(5) >>> a[2].append(6) >>> a [[4], [5], [6]] 164

165 제자리에서변경이 가능핚가? 165

166 그런것 : 리스트, 사전 안그런것 : 문자열, 튜플 166

167 하여튼 167

168 망한값들 자료형 person 미지의세계 값 person ( 클래스 ) * * * * 자료형 person 미지의세계 환경 값 person ( 클래스 ) * * * * person p 168

169 자료형 person 미지의세계 환경 값 person ( 클래스 ) * * * * person p 169

170 가비지컬렉션 = 망핚값처리하기 170

171 >>> p = person(' 강성훈 ', 1987, 9, 13) >>> print p. str () 강성훈 - 9월 13일생 >>> print str(p) 강성훈 - 9월 13일생 >>> print p 강성훈 - 9월 13일생 171

172 마무리 172

173 # coding=cp949 class person(object): def init (self, ): def str (self, ): birthdays = [ person(' 강성훈 ', 1987, 9, 13), person(' 정재성 ', 1987, 2, 23), person(' 김준기 ', 1987, 5, 12), ] 173

174 def printnames(birthdays): names = [p.name for p in birthdays] names.sort() print ', '.join(names) def printbirthdays(birthdays): for p in birthdays: print p 174

175 def printbyname(birthdays): name = raw_input(' 이름을입력하세요 : ') filtered = [p for p in birthdays if p.name == name] printbirthdays(filtered) def printbyyear(birthdays): year = inputnum(' 생년을입력하세요 : ') filtered = [p for p in birthdays if p.year == year] printbirthdays(filtered) 175

176 더고칠거리를 생각해보세요! 176

177 끝? 177

178 세상모든일이 이렇게잘풀리짂 않겠지만 178

179 리팩토링 테스팅 디버깅 문서화 이건안했지만 179

180 모듈을꼭우리만 만들란법이있나 180

181 바퀴를재발명하기 181

182 182

183 >>> import sys >>> sys.version '2.6.2 (r262:71605, Apr , 22:40:02) [MSC v bit (Intel)]' 183

184 >>> import math >>> math.sqrt(2) >>> 2 ** >>> math.factorial(16) L 184

185 >>> import datetime >>> datetime.date.today() datetime.date(2010, 3, 12) >>> _.weekday() 4 >>> print [' 월 ',' 화 ',' 수 ',' 목 ',' 금 ',... ' 토 ',' 일 '][_] 금 185

186 >>> import random >>> menus = [' 짜장 ', ' 짬뽕 ', ' 짜짬면 '] >>> print menus[random.randint(0,... len(menus)-1)] 짜장 >>> print random.choice(menus) 짬뽕 186

187 >>> import urllib >>> for line in urllib.urlopen(... ' 'www/popclockworld.html'):... if 'worldnumber' in line:... print line[45:-14]... 6,807,870,

188 188

189 레퍼런스는정독해도 부족함이없습니다 189

190 그밖에 Numpy라거나 Django라거나 Pyglet이라거나 190

191 안다룬것들 191

192 클래스에대핚자세핚내용 set, unicode 같은자료형들 외부라이브러리쓰기 패키지다루기 그밖에파이썬을쓰면서필요하게될수많은조언들 192

193 두시갂안에하긴 좀벅찬지라 193

194 질문과답변? 194

195 감사합니다. 너무길어서정말로죄송 195

196 덤 196

197 슬라이드목차 #1 시작 #4 왜파이썬을배우는가? #13 계산기로쓰기, 자료형 #25 변수, 조건문, 반복문 #36 리팩토링, 함수 #44 리스트, 튜플 #58 메소드, 값으로서의자료형 #72 내장함수및메소드 #86 아젠다설정 #92 모듈 #106 생년월일프로그램의뼈대 #116 내장도움말 #120 리팩토링 (2), 방어적프로그래밍, 예외 #132 생년월일프로그램의뼈대 (2) #140 리팩토링 (3) #148 클래스 #159 파이썬메모리의구조 #172 생년월일프로그램의마무리 #180 파이썬내장라이브러리 #191 안다룬것들 197

198 표기컨벤션 코드및대화식홖경은노란배경으로, 프로그램출력은파란배경으로, 직접입력하지않은내용은옅은색으로, 이벆슬라이드에처음등장하는문법 심볼은붉은색으로, ( 단, 공백등은별도표시안함 ) 파이썬프롬포트및예약어는굵게표기했음. 198

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf("hihi\n"); } warning: conflicting types for functiona

4. #include <stdio.h> #include <stdlib.h> int main() { functiona(); } void functiona() { printf(hihi\n); } warning: conflicting types for functiona 이름 : 학번 : A. True or False: 각각항목마다 True 인지 False 인지적으세요. 1. (Python:) randint 함수를사용하려면, random 모듈을 import 해야한다. 2. (Python:) '' (single quote) 는한글자를표현할때, (double quote) 는문자열을표현할때사용한다. B. 다음에러를수정하는방법을적으세요.

More information

슬라이드 1

슬라이드 1 기초 PYTHON 프로그래밍 14. 함수 - 1 1. 함수 2. 파이썬내장함수 3. 사용자정의함수 4. 함수의인수와반환값 5. 함수의위치와 main 작성하기 1. 함수 블랙박스 (black box) 함수는입력과출력을갖는 black box이다. 주어진입력에대해서어떤과정을거쳐출력이나오는지가숨겨져있다. >>> print('hello world') Hello world

More information

17장 클래스와 메소드

17장 클래스와 메소드 17 장클래스와메소드 박창이 서울시립대학교통계학과 박창이 ( 서울시립대학교통계학과 ) 17 장클래스와메소드 1 / 18 학습내용 객체지향특징들객체출력 init 메소드 str 메소드연산자재정의타입기반의버전다형성 (polymorphism) 박창이 ( 서울시립대학교통계학과 ) 17 장클래스와메소드 2 / 18 객체지향특징들 객체지향프로그래밍의특징 프로그램은객체와함수정의로구성되며대부분의계산은객체에대한연산으로표현됨객체의정의는

More information

8장 문자열

8장 문자열 8 장문자열 박창이 서울시립대학교통계학과 박창이 ( 서울시립대학교통계학과 ) 8 장문자열 1 / 24 학습내용 문자열 (string) 훑기 (traversal) 부분추출 (slicing) print 함수불변성 (immutablity) 검색 (search) 세기 (count) Method in 연산자비교 박창이 ( 서울시립대학교통계학과 ) 8 장문자열 2 /

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 클래스, 객체, 메소드 ( 실습 ) 손시운 ssw5176@kangwon.ac.kr 예제 1. 필드만있는클래스 텔레비젼 2 예제 1. 필드만있는클래스 3 예제 2. 여러개의객체생성하기 4 5 예제 3. 메소드가추가된클래스 public class Television { int channel; // 채널번호 int volume; // 볼륨 boolean

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 파이썬을이용한빅데이터수집. 분석과시각화 Part 2. 데이터시각화 이원하 목 차 1 2 3 4 WordCloud 자연어처리 Matplotlib 그래프 Folium 지도시각화 Seabean - Heatmap 03 07 16 21 1 WORDCLOUD - 자연어처리 KoNLPy 형태소기반자연어처리 http://www.oracle.com/technetwork/java/javase/downloads/index.html

More information

3장 함수

3장 함수 3 장함수 박창이 서울시립대학교통계학과 박창이 ( 서울시립대학교통계학과 ) 3 장함수 1 / 20 학습내용 함수호출타입변환함수수학함수사용자정의함수파라미터와인자변수와파라미터의범위함수의구분함수를사용하는이유 from을이용한가져오기디버깅변수의범위재귀함수 박창이 ( 서울시립대학교통계학과 ) 3 장함수 2 / 20 함수호출 함수는어떤연산을수행하는일련의명령문들로함수이름으로호출

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 2... ( ). ( ). @ vs. logic data method variable behavior attribute method field Flow (Type), ( ) member @ () : C program Method A ( ) Method B ( ) Method C () program : Java, C++, C# data @ Program

More information

Week5

Week5 Week 05 Iterators, More Methods and Classes Hash, Regex, File I/O Joonhwan Lee human-computer interaction + design lab. Iterators Writing Methods Classes & Objects Hash File I/O Quiz 4 1. Iterators Array

More information

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각

JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 (   ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각 JAVA 프로그래밍실습 실습 1) 실습목표 - 메소드개념이해하기 - 매개변수이해하기 - 새메소드만들기 - Math 클래스의기존메소드이용하기 ( http://java.sun.com/javase/6/docs/api ) 문제 - 직사각형모양의땅이있다. 이땅의둘레, 면적과대각선의길이를계산하는메소드들을작성하라. 직사각형의가로와세로의길이는주어진다. 대각선의길이는 Math클래스의적절한메소드를이용하여구하라.

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 실습 1 배효철 th1g@nate.com 1 목차 조건문 반복문 System.out 구구단 모양만들기 Up & Down 2 조건문 조건문의종류 If, switch If 문 조건식결과따라중괄호 { 블록을실행할지여부결정할때사용 조건식 true 또는 false값을산출할수있는연산식 boolean 변수 조건식이 true이면블록실행하고 false 이면블록실행하지않음 3

More information

Microsoft PowerPoint - Java7.pptx

Microsoft PowerPoint - Java7.pptx HPC & OT Lab. 1 HPC & OT Lab. 2 실습 7 주차 Jin-Ho, Jang M.S. Hanyang Univ. HPC&OT Lab. jinhoyo@nate.com HPC & OT Lab. 3 Component Structure 객체 (object) 생성개념을이해한다. 외부클래스에대한접근방법을이해한다. 접근제어자 (public & private)

More information

p. 10 Before You Read............... p. 26 Understanding the Story ( ).,.,..,,...,...

p. 10 Before You Read............... p. 26 Understanding the Story ( ).,.,..,,...,... Grade 3-1 p. 4 19.., 1851.,,. 55. 62.,,,. 82 90. p. 5.?. 1885..,,. p. 10 Before You Read............... p. 26 Understanding the Story ( ).,.,..,,...,... ... p. 44 Before You Read,.....!.,.,......!......!

More information

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx

Microsoft PowerPoint - chap02-C프로그램시작하기.pptx #include int main(void) { int num; printf( Please enter an integer "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; } 1 학습목표 을 작성하면서 C 프로그램의

More information

14장 파일

14장 파일 14 장파일 박창이 서울시립대학교통계학과 박창이 ( 서울시립대학교통계학과 ) 14 장파일 1 / 18 학습내용 파일입출력예포멧연산자 (format operator) 파일명과경로예외처리하기피클링 (pickling) 파일입출력디버깅 박창이 ( 서울시립대학교통계학과 ) 14 장파일 2 / 18 파일입출력예 >>> fout = open( output.txt, w )

More information

12-file.key

12-file.key 11 (String).. java.lang.stringbuffer. s String s = "abcd"; s = s + "e"; a b c d e a b c d e ,., "910359,, " "910359" " " " " (token) (token),, (delimiter). java.util.stringtokenizer String s = "910359,,

More information

歯처리.PDF

歯처리.PDF E06 (Exception) 1 (Report) : { $I- } { I/O } Assign(InFile, InputName); Reset(InFile); { $I+ } { I/O } if IOResult 0 then { }; (Exception) 2 2 (Settling State) Post OnValidate BeforePost Post Settling

More information

PowerPoint Presentation

PowerPoint Presentation Package Class 3 Heeseung Jo 목차 section 1 패키지개요와패키지의사용 section 2 java.lang 패키지의개요 section 3 Object 클래스 section 4 포장 (Wrapper) 클래스 section 5 문자열의개요 section 6 String 클래스 section 7 StringBuffer 클래스 section

More information

Multi-pass Sieve를 이용한 한국어 상호참조해결 반-자동 태깅 도구

Multi-pass Sieve를 이용한 한국어 상호참조해결 반-자동 태깅 도구 Python: 파이썬프로그래밍의기초, 함수 Kangwon Natl. University Department of Computer Science Cheoneum Park Intelligent software Lab. 함수 Intelligent software Lab. 2 함수란무엇인가? Intelligent software Lab. 3 함수를사용하는이유는? 프로그래밍을하다보면똑같은내용을반복해서작성하는경우다반사

More information

C 프로그래밍 언어 입문 C 프로그래밍 언어 입문 김명호저 숭실대학교 출판국 머리말..... C, C++, Java, Fortran, Python, Ruby,.. C. C 1972. 40 C.. C. 1999 C99. C99. C. C. C., kmh ssu.ac.kr.. ,. 2013 12 Contents 1장 프로그래밍 시작 1.1 C 10 1.2 12

More information

A Review of C Programming

A Review of C Programming 02 장파이썬프로그래밍의 기초, 자료형 자료형을알고있다면그언어의절반을터득한것 02-1 숫자형 정수형 (1, 2, -2) 실수 (1.24, -34.56) 컴퓨터식지수표현방식 (4.24e10, 4.24e-10) 복소수 (1+2j) 8진수 (0o37) 16진수 (0x7A) 2 02-1 숫자형 사칙연산 >>> a = 3 >>> b = 4 >>> a + b 7 >>>

More information

OCaml

OCaml OCaml 2009.. (khheo@ropas.snu.ac.kr) 1 ML 2 ML OCaml INRIA, France SML Bell lab. & Princeton, USA nml SNU/KAIST, KOREA 3 4 (let) (* ex1.ml *) let a = 10 let add x y = x + y (* ex2.ml *) let sumofsquare

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 파이썬을이용한빅데이터수집. 분석과시각화 이원하 목 차 1 2 3 4 5 Python 설치변수와파이썬자료형 (Data Type) 흐름제어입력 (Input) 과출력 (Output) 함수 (Function) 03 10 38 48 57 6 모듈 (Module) 62 1 1 PYTHON 설치 WHY PYTHON https://www.python.org 4 Download

More information

유니티 변수-함수.key

유니티 변수-함수.key C# 1 or 16 (Binary or Hex) 1:1 C# C# (Java, Python, Go ) (0101010 ). (Variable) : (Value) (Variable) : (Value) ( ) (Variable) : (Value) ( ) ; (Variable) : (Value) ( ) ; = ; (Variable) : (Value) (Variable)

More information

SIGPLwinterschool2012

SIGPLwinterschool2012 1994 1992 2001 2008 2002 Semantics Engineering with PLT Redex Matthias Felleisen, Robert Bruce Findler and Matthew Flatt 2009 Text David A. Schmidt EXPRESSION E ::= N ( E1 O E2 ) OPERATOR O ::=

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 @ Lesson 3 if, if else, if else if, switch case for, while, do while break, continue : System.in, args, JOptionPane for (,, ) @ vs. logic data method variable Data Data Flow (Type), ( ) @ Member field

More information

는 우연히 안나를 알게 되고, 이후 두 사람은 서로 격렬한 사랑에 빠진다. 결국 안나가 브 론스키의 아이를 임신하게 되자, 브론스키는 안나가 카레닌과 이혼하고 자기와 함께 새로 운 생활을 하길 바라지만, 안나는 아들 때문에 망설인다. 한편, 카레닌은 브론스키를 사랑 한

는 우연히 안나를 알게 되고, 이후 두 사람은 서로 격렬한 사랑에 빠진다. 결국 안나가 브 론스키의 아이를 임신하게 되자, 브론스키는 안나가 카레닌과 이혼하고 자기와 함께 새로 운 생활을 하길 바라지만, 안나는 아들 때문에 망설인다. 한편, 카레닌은 브론스키를 사랑 한 한글 번역 Grade 5-9 안나 카레니나 p. 4 이 책의 저자 톨스토이 (1828~1910) 19세기 러시아 문학을 대표하는 세계적 작가인 동시에 사상가. 유서 깊은 백작 집안의 넷째 아들로 태어났다. 대학을 중퇴한 후 고향으로 돌아와 지주로서 영지 내 농민생활의 개선을 위해 노력하였으나, 그의 이상주의는 실패로 끝나 모스크바에서 방탕한 생활에 빠 져들었고

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Programming Languages 모듈과펑터 2016 년봄학기 손시운 (ssw5176@kangwon.ac.kr) 담당교수 : 임현승교수님 모듈 (module) 관련있는정의 ( 변수또는함수 ) 를하나로묶은패키지 예약어 module과 struct end를사용하여정의 아래는모듈의예시 ( 우선순위큐, priority queue) # module PrioQueue

More information

Microsoft PowerPoint - 04-UDP Programming.ppt

Microsoft PowerPoint - 04-UDP Programming.ppt Chapter 4. UDP Dongwon Jeong djeong@kunsan.ac.kr http://ist.kunsan.ac.kr/ Dept. of Informatics & Statistics 목차 UDP 1 1 UDP 개념 자바 UDP 프로그램작성 클라이언트와서버모두 DatagramSocket 클래스로생성 상호간통신은 DatagramPacket 클래스를이용하여

More information

치밀한 시간 계산으로 한 치의 오차 없이 여행일정을 계획하지만, 상황이 항상 뜻대로 돌 아가지는 않는다. 인도에서는 철로가 끊겨 있기도 하고, 미국에서는 인디언의 공격을 받 기도 한다. 하지만 그는 항상 침착하고 냉정한 태도를 유지하며, 때로는 일정에 차질이 생 겨도

치밀한 시간 계산으로 한 치의 오차 없이 여행일정을 계획하지만, 상황이 항상 뜻대로 돌 아가지는 않는다. 인도에서는 철로가 끊겨 있기도 하고, 미국에서는 인디언의 공격을 받 기도 한다. 하지만 그는 항상 침착하고 냉정한 태도를 유지하며, 때로는 일정에 차질이 생 겨도 한글 번역 Grade 3-9 80일간의 세계일주 p. 4 이 책의 저자 쥘 베른 (1828~1905) 과학 모험 소설가로 유명한 쥘 베른은 1828년 프랑스의 항구도시 낭트에서 태어났 다. 그는 어렸을 때부터 바다와 모험을 동경하고 독서와 글쓰기를 좋아하였으나, 아버지 의 뜻에 따라 파리에서 법률을 공부하고 졸업 후에는 사업가, 주식 중개인 등으로 일하였 다.

More information

2) 활동하기 활동개요 활동과정 [ 예제 10-1]main.xml 1 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 2 xmlns:tools="http://schemas.android.

2) 활동하기 활동개요 활동과정 [ 예제 10-1]main.xml 1 <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android 2 xmlns:tools=http://schemas.android. 10 차시파일처리 1 학습목표 내장메모리의파일을처리하는방법을배운다. SD 카드의파일을처리하는방법을배운다. 2 확인해볼까? 3 내장메모리파일처리 1) 학습하기 [ 그림 10-1] 내장메모리를사용한파일처리 2) 활동하기 활동개요 활동과정 [ 예제 10-1]main.xml 1

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 두근두근 파이썬수업 4 장자료의종류에는어떤것들이있나요? 이번장에서만들프로그램 (1) 터틀그래픽의거북이와인사하는프로그램을작성해보자. Run Python (2) 여러개의색상을리스트에저장하였다가하나씩꺼내서원들을그려보자 Run Python 파이썬에서사용할수있는자료의종류 파이썬과자료형 변수에어떤종류의자료도저장할수있다 x = 10 print("x =", x) x = 3.14

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 프로그램에서자료들을저장하는여러가지구조들이있다. 이를자료구조 (data structure) 라부른다. 시퀀스에속하는자료구조들은동일한연산을지원한다. 인덱싱 (indexing), 슬라이싱 (slicing), 덧셈연산 (adding), 곱셈연산 (multiplying) 리스트는앞에서자세하게살펴본바있다. 여기서는나머지시퀀스들을탐구해보자. 튜플 (tuple) 은변경될수없는리스트

More information

Modern Javascript

Modern Javascript ES6 - Arrow Function Class Template String Destructuring Default, Rest, Spread let, const for..of Promises Module System Map, Set * Generator * Symbol * * https://babeljs.io/ Babel is a JavaScript compiler.

More information

JAVA PROGRAMMING 실습 05. 객체의 활용

JAVA PROGRAMMING 실습 05. 객체의 활용 2015 학년도 2 학기 public class Person{ public String name; public int age; public Person(){ public Person(String s, int a){ name = s; age = a; public String getname(){ return name; @ 객체의선언 public static void

More information

C 언어 프로그래밊 과제 풀이

C 언어 프로그래밊 과제 풀이 과제풀이 (1) 홀수 / 짝수판정 (1) /* 20094123 홍길동 20100324 */ /* even_or_odd.c */ /* 정수를입력받아홀수인지짝수인지판정하는프로그램 */ int number; printf(" 정수를입력하시오 => "); scanf("%d", &number); 확인 주석문 가필요한이유 printf 와 scanf 쌍

More information

슬라이드 1

슬라이드 1 / 유닉스시스템개요 / 파일 / 프로세스 01 File Descriptor file file descriptor file type unix 에서의파일은단지바이트들의나열임 operating system 은파일에어떤포맷도부과하지않음 파일의내용은바이트단위로주소를줄수있음 file descriptor 는 0 이나양수임 file 은 open 이나 creat 로 file

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 리스트 (list) 는여러개의데이터가저장되어있는장소이다. scores = [ 32, 56, 64, 72, 12, 37, 98, 77, 59, 69] scores = [ ] for i in range(10): scores.append(int(input(" 성적을입력하시오 :"))) print(scores) scores = [ 32, 56, 64, 72, 12,

More information

Web Scraper in 30 Minutes 강철

Web Scraper in 30 Minutes 강철 Web Scraper in 30 Minutes 강철 발표자 소개 KAIST 전산학과 2015년부터 G사에서 일합니다. 에서 대한민국 정치의 모든 것을 개발하고 있습니다. 목표 웹 스크래퍼를 프레임웍 없이 처음부터 작성해 본다. 목표 웹 스크래퍼를 프레임웍 없이 처음부터 작성해 본다. 스크래퍼/크롤러의 작동 원리를 이해한다. 목표

More information

Microsoft Word _mentor_conf_output5.docx

Microsoft Word _mentor_conf_output5.docx < 이재성교수님연구실멘토링자료 > 20151012 최현준제작 # 목차 1. 간단한파이썬 1.1 파이썬설치및설명. 1.2 파이썬데이터형과연산자. 1.3 간단한입출력과형변환. 1.4 for, while, if, with ~ as, indent. 1.5 def 함수정의와 default / return values 1.6 import 와 try except, pip.

More information

C++ Programming

C++ Programming C++ Programming 연산자다중정의 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 연산자다중정의 C++ 스타일의문자열 2 연산자다중정의 연산자다중정의 단항연산자다중정의 이항연산자다중정의 cin, cout 그리고 endl C++ 스타일의문자열 3 연산자다중정의 연산자다중정의 (Operator

More information

Microsoft PowerPoint - C++ 5 .pptx

Microsoft PowerPoint - C++ 5 .pptx C++ 언어프로그래밍 한밭대학교전자. 제어공학과이승호교수 연산자중복 (operator overloading) 이란? 2 1. 연산자중복이란? 1) 기존에미리정의되어있는연산자 (+, -, /, * 등 ) 들을프로그래머의의도에맞도록새롭게정의하여사용할수있도록지원하는기능 2) 연산자를특정한기능을수행하도록재정의하여사용하면여러가지이점을가질수있음 3) 하나의기능이프로그래머의의도에따라바뀌어동작하는다형성

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 함수 (function) 는특정작업을수행하는명령어들의모음에이름을붙인것 함수는작업에필요한데이터를전달받을수있으며, 작업이완료된후에는작업의결과를호출자에게반환할수있다. print() input() abs(), 함수안의명령어들을실행하려면함수를호출 (call) 하면된다. >>> value = abs(-100) >>> value 100 >>>def say_hello(name):

More information

APCPCWM_ :WP_GLOBAL_PFWP_GLOBAL_PF APCPCWM_ :WP_GLOBAL_PFWP_GLOBAL_PF 예제로보는 네트워크엔지니어를위한 Python 101

APCPCWM_ :WP_GLOBAL_PFWP_GLOBAL_PF APCPCWM_ :WP_GLOBAL_PFWP_GLOBAL_PF 예제로보는 네트워크엔지니어를위한 Python 101 예제로보는 네트워크엔지니어를위한 Python 101 오늘의목표 NO NO YES Python Basic Indentation Python에서 Indentation으로 Code Block(Scope) 를구분 동일한 Code Block은동일한방법 (Space, Tab) 으로구분해야함 하위레벨의 Code Block 나오기전에는 : ( 콜론 ) 사용 Indent

More information

Microsoft PowerPoint 자바-기본문법(Ch2).pptx

Microsoft PowerPoint 자바-기본문법(Ch2).pptx 자바기본문법 1. 기본사항 2. 자료형 3. 변수와상수 4. 연산자 1 주석 (Comments) 이해를돕기위한설명문 종류 // /* */ /** */ 활용예 javadoc HelloApplication.java 2 주석 (Comments) /* File name: HelloApplication.java Created by: Jung Created on: March

More information

1

1 1 1....6 1.1...6 2. Java Architecture...7 2.1 2SDK(Software Development Kit)...8 2.2 JRE(Java Runtime Environment)...9 2.3 (Java Virtual Machine, JVM)...10 2.4 JVM...11 2.5 (runtime)jvm...12 2.5.1 2.5.2

More information

10 강. 쉘스크립트 l 쉘스크립트 Ÿ 쉘은명령어들을연속적으로실행하는인터프리터환경을제공 Ÿ 쉘스크립트는제어문과변수선언등이가능하며프로그래밍언어와유사 Ÿ 프로그래밍언어와스크립트언어 -프로그래밍언어를사용하는경우소스코드를컴파일하여실행가능한파일로만들어야함 -일반적으로실행파일은다

10 강. 쉘스크립트 l 쉘스크립트 Ÿ 쉘은명령어들을연속적으로실행하는인터프리터환경을제공 Ÿ 쉘스크립트는제어문과변수선언등이가능하며프로그래밍언어와유사 Ÿ 프로그래밍언어와스크립트언어 -프로그래밍언어를사용하는경우소스코드를컴파일하여실행가능한파일로만들어야함 -일반적으로실행파일은다 10 강. 쉘스크립트 쉘스크립트 쉘은명령어들을연속적으로실행하는인터프리터환경을제공 쉘스크립트는제어문과변수선언등이가능하며프로그래밍언어와유사 프로그래밍언어와스크립트언어 -프로그래밍언어를사용하는경우소스코드를컴파일하여실행가능한파일로만들어야함 -일반적으로실행파일은다른운영체제로이식되지않음 -스크립트언어를사용하면컴파일과정이없고인터프리터가소스파일에서명령문을판독하여각각의명령을수행

More information

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202839C1D6C2F7207E203135C1D6C2F >

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202839C1D6C2F7207E203135C1D6C2F > 10주차 문자 LCD 의인터페이스회로및구동함수 Next-Generation Networks Lab. 5. 16x2 CLCD 모듈 (HY-1602H-803) 그림 11-18 19 핀설명표 11-11 번호 분류 핀이름 레벨 (V) 기능 1 V SS or GND 0 GND 전원 2 V Power DD or V CC +5 CLCD 구동전원 3 V 0 - CLCD 명암조절

More information

Microsoft PowerPoint - chap05-제어문.pptx

Microsoft PowerPoint - chap05-제어문.pptx int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); 1 학습목표 제어문인,, 분기문에 대해 알아본다. 인 if와 switch의 사용 방법과 사용시 주의사항에 대해 알아본다.

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Chapter 2 문자열 (string) 다루기형변환 (type casting) 2014. 5. 29 문자열 문자열은 (single quote) 또는 (double quote) 로묶인문자 (character) 들의열이다. Python 에서문자열은시퀀스 (sequence) 자료형이다. 시퀀스자료형 여러객체들을저장하는저장자료형 각객체들은순서를가짐 순서를가지므로각요소들은첨자

More information

파일로입출력하기II - 파일출력클래스중에는데이터를일정한형태로출력하는기능을가지고있다. - PrintWriter와 PrintStream을사용해서원하는형태로출력할수있다. - PrintStream은구버전으로가능하면 PrintWriter 클래스를사용한다. PrintWriter

파일로입출력하기II - 파일출력클래스중에는데이터를일정한형태로출력하는기능을가지고있다. - PrintWriter와 PrintStream을사용해서원하는형태로출력할수있다. - PrintStream은구버전으로가능하면 PrintWriter 클래스를사용한다. PrintWriter 파일로입출력하기II - 파일출력클래스중에는데이터를일정한형태로출력하는기능을가지고있다. - PrintWriter와 PrintStream을사용해서원하는형태로출력할수있다. - PrintStream은구버전으로가능하면 PrintWriter 클래스를사용한다. PrintWriter 클래스의사용법은다음과같다. PrintWriter writer = new PrintWriter("output.txt");

More information

Cluster management software

Cluster management software 자바네트워크프로그래밍 (OCJP 국제공인자격취득중심 ) 충북대학교 최민 기본예제 예외클래스를정의하고사용하는예제 class NewException extends Exception { public class ExceptionTest { static void methoda() throws NewException { System.out.println("NewException

More information

C++ Programming

C++ Programming C++ Programming 예외처리 Seo, Doo-okok clickseo@gmail.com http://www.clickseo.com 목 차 예외처리 2 예외처리 예외처리 C++ 의예외처리 예외클래스와객체 3 예외처리 예외를처리하지않는프로그램 int main() int a, b; cout > a >> b; cout

More information

JAVA PROGRAMMING 실습 05. 객체의 활용

JAVA PROGRAMMING 실습 05. 객체의 활용 public class Person{ public String name; public int age; } public Person(){ } public Person(String s, int a){ name = s; age = a; } public String getname(){ return name; } @ 객체의선언 public static void main(string

More information

Secure Programming Lecture1 : Introduction

Secure Programming Lecture1 : Introduction Malware and Vulnerability Analysis Lecture3-2 Malware Analysis #3-2 Agenda 안드로이드악성코드분석 악성코드분석 안드로이드악성코드정적분석 APK 추출 #1 adb 명령 안드로이드에설치된패키지리스트추출 adb shell pm list packages v0nui-macbook-pro-2:lecture3 v0n$

More information

슬라이드 1

슬라이드 1 UNIT 08 조건문과반복문 로봇 SW 교육원 2 기 학습목표 2 조건문을사용핛수있다. 반복문을사용핛수있다. 조건문 3 조건식의연산결과에따라프로그램의실행흐름을변경 조건문의구성 조건식 실행될문장 조건문의종류 if switch? : ( 삼항연산자 ) if 조건문 4 if 문의구성 조건식 true 또는 false(boolean 형 ) 의결과값을갖는수식 실행될문장

More information

강의10

강의10 Computer Programming gdb and awk 12 th Lecture 김현철컴퓨터공학부서울대학교 순서 C Compiler and Linker 보충 Static vs Shared Libraries ( 계속 ) gdb awk Q&A Shared vs Static Libraries ( 계속 ) Advantage of Using Libraries Reduced

More information

JUNIT 실습및발표

JUNIT 실습및발표 JUNIT 실습및발표 JUNIT 접속 www.junit.org DownLoad JUnit JavaDoc API Document 를참조 JUNIT 4.8.1 다운로드 설치파일 (jar 파일 ) 을다운로드 CLASSPATH 를설정 환경변수에서설정 실행할클래스에서 import JUnit 설치하기 테스트실행주석 @Test Test 를실행할 method 앞에붙임 expected

More information

untitled

untitled Push... 2 Push... 4 Push... 5 Push... 13 Push... 15 1 FORCS Co., LTD A Leader of Enterprise e-business Solution Push (Daemon ), Push Push Observer. Push., Observer. Session. Thread Thread. Observer ID.

More information

확률 및 분포

확률 및 분포 확률및분포 박창이 서울시립대학교통계학과 박창이 ( 서울시립대학교통계학과 ) 확률및분포 1 / 15 학습내용 조건부확률막대그래프히스토그램선그래프산점도참고 박창이 ( 서울시립대학교통계학과 ) 확률및분포 2 / 15 조건부확률 I 첫째가딸일때두아이모두딸일확률 (1/2) 과둘중의하나가딸일때둘다딸일확률 (1/3) 에대한모의실험 >>> from collections import

More information

JAVA PROGRAMMING 실습 02. 표준 입출력

JAVA PROGRAMMING 실습 02. 표준 입출력 자바의기본구조? class HelloJava{ public static void main(string argv[]){ system.out.println( hello,java ~ ){ } } # 하나하나뜯어살펴봅시다! public class HelloJava{ 클래스정의 public static void main(string[] args){ System.out.println(

More information

Java

Java Java http://cafedaumnet/pway Chapter 1 1 public static String format4(int targetnum){ String strnum = new String(IntegertoString(targetNum)); StringBuffer resultstr = new StringBuffer(); for(int i = strnumlength();

More information

슬라이드 1

슬라이드 1 Pairwise Tool & Pairwise Test NuSRS 200511305 김성규 200511306 김성훈 200614164 김효석 200611124 유성배 200518036 곡진화 2 PICT Pairwise Tool - PICT Microsoft 의 Command-line 기반의 Free Software www.pairwise.org 에서다운로드후설치

More information

Microsoft PowerPoint - lec2.ppt

Microsoft PowerPoint - lec2.ppt 2008 학년도 1 학기 상지대학교컴퓨터정보공학부 고광만 강의내용 어휘구조 토큰 주석 자료형기본자료형 참조형배열, 열거형 2 어휘 (lexicon) 어휘구조와자료형 프로그램을구성하는최소기본단위토큰 (token) 이라부름문법적으로의미있는최소의단위컴파일과정의어휘분석단계에서처리 자료형 자료객체가갖는형 구조, 개념, 값, 연산자를정의 3 토큰 (token) 정의문법적으로의미있는최소의단위예,

More information

PowerPoint Presentation

PowerPoint Presentation Class - Property Jo, Heeseung 목차 section 1 클래스의일반구조 section 2 클래스선언 section 3 객체의생성 section 4 멤버변수 4-1 객체변수 4-2 클래스변수 4-3 종단 (final) 변수 4-4 멤버변수접근방법 section 5 멤버변수접근한정자 5-1 public 5-2 private 5-3 한정자없음

More information

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx

Microsoft PowerPoint - java1-lab5-ImageProcessorTestOOP.pptx 2018 학년도 1 학기 JAVA 프로그래밍 II 514760-1 2018 년봄학기 5/10/2018 박경신 Lab#1 (ImageTest) Lab#1 은영상파일 (Image) 을읽어서정보를출력 Java Tutorials Lesson: Working with Images https://docs.oracle.com/javase/tutorial/2d/images/index.html

More information

vi 사용법

vi 사용법 유닉스프로그래밍및실습 gdb 사용법 fprintf 이용 단순디버깅 확인하고자하는코드부분에 fprintf(stderr, ) 를이용하여그지점까지도달했는지여부와관심있는변수의값을확인 여러유형의단순한문제를확인할수있음 그러나자세히살펴보기위해서는디버깅툴필요 int main(void) { int count; long large_no; double real_no; init_vars();

More information

제이쿼리 (JQuery) 정의 자바스크립트함수를쉽게사용하기위해만든자바스크립트라이브러리. 웹페이지를즉석에서변경하는기능에특화된자바스크립트라이브러리. 사용법 $( 제이쿼리객체 ) 혹은 $( 엘리먼트 ) 참고 ) $() 이기호를제이쿼리래퍼라고한다. 즉, 제이쿼리를호출하는기호

제이쿼리 (JQuery) 정의 자바스크립트함수를쉽게사용하기위해만든자바스크립트라이브러리. 웹페이지를즉석에서변경하는기능에특화된자바스크립트라이브러리. 사용법 $( 제이쿼리객체 ) 혹은 $( 엘리먼트 ) 참고 ) $() 이기호를제이쿼리래퍼라고한다. 즉, 제이쿼리를호출하는기호 제이쿼리 () 정의 자바스크립트함수를쉽게사용하기위해만든자바스크립트라이브러리. 웹페이지를즉석에서변경하는기능에특화된자바스크립트라이브러리. 사용법 $( 제이쿼리객체 ) 혹은 $( 엘리먼트 ) 참고 ) $() 이기호를제이쿼리래퍼라고한다. 즉, 제이쿼리를호출하는기호 CSS와마찬가지로, 문서에존재하는여러엘리먼트를접근할수있다. 엘리먼트접근방법 $( 엘리먼트 ) : 일반적인접근방법

More information

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074> Chap #2 펌웨어작성을위한 C 언어 I http://www.smartdisplay.co.kr 강의계획 Chap1. 강의계획및디지털논리이론 Chap2. 펌웨어작성을위한 C 언어 I Chap3. 펌웨어작성을위한 C 언어 II Chap4. AT89S52 메모리구조 Chap5. SD-52 보드구성과코드메모리프로그래밍방법 Chap6. 어드레스디코딩 ( 매핑 ) 과어셈블리어코딩방법

More information

07 자바의 다양한 클래스.key

07 자바의 다양한 클래스.key [ 07 ] . java.lang Object, Math, String, StringBuffer Byte, Short, Integer, Long, Float, Double, Boolean, Character. java.util Random, StringTokenizer Calendar, GregorianCalendar, Date. Collection, List,

More information

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770>

<322EBCF8C8AF28BFACBDC0B9AEC1A6292E687770> 연습문제해답 5 4 3 2 1 0 함수의반환값 =15 5 4 3 2 1 0 함수의반환값 =95 10 7 4 1-2 함수의반환값 =3 1 2 3 4 5 연습문제해답 1. C 언어에서의배열에대하여다음중맞는것은? (1) 3차원이상의배열은불가능하다. (2) 배열의이름은포인터와같은역할을한다. (3) 배열의인덱스는 1에서부터시작한다. (4) 선언한다음, 실행도중에배열의크기를변경하는것이가능하다.

More information

Polly_with_Serverless_HOL_hyouk

Polly_with_Serverless_HOL_hyouk { } "Version":"2012-10-17", "Statement":[ { "Effect":"Allow", "Action":[ "polly:synthesizespeech", "dynamodb:query", "dynamodb:scan", "dynamodb:putitem", "dynamodb:updateitem", "sns:publish", "s3:putobject",

More information

slide2

slide2 Program P ::= CL CommandList CL ::= C C ; CL Command C ::= L = E while E : CL end print L Expression E ::= N ( E + E ) L &L LefthandSide L ::= I *L Variable I ::= Numeral N ::=

More information

歯9장.PDF

歯9장.PDF 9 Hello!! C printf() scanf() getchar() putchar() gets() puts() fopen() fclose() fprintf() fscant() fgetc() fputs() fgets() gputs() fread() fwrite() fseek() ftell() I/O 2 (stream) C (text stream) : `/n'

More information

쉽게

쉽게 Power Java 제 4 장자바프로그래밍기초 이번장에서학습할내용 자바프로그램에대한기초사항을학습 자세한내용들은추후에. Hello.java 프로그램 주석 주석 (comment): 프로그램에대한설명을적어넣은것 3 가지타입의주석 클래스 클래스 (class): 객체를만드는설계도 ( 추후에학습 ) 자바프로그램은클래스들로구성된다. 그림 4-1. 자바프로그램의구조 클래스정의

More information

중간고사

중간고사 중간고사 예제 1 사용자로부터받은두개의숫자 x, y 중에서큰수를찾는알고리즘을의사코드로작성하시오. Step 1: Input x, y Step 2: if (x > y) then MAX

More information

09-interface.key

09-interface.key 9 Database insert(record r): boolean find(key k): Record 1 Record getkey(): Key * Record Key Database.? Key equals(key y): boolean Database insert(record r): boolean find(key k): Record * Database OK 1

More information

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt

Microsoft PowerPoint - 3ÀÏ°_º¯¼ö¿Í »ó¼ö.ppt 변수와상수 1 변수란무엇인가? 변수 : 정보 (data) 를저장하는컴퓨터내의특정위치 ( 임시저장공간 ) 메모리, register 메모리주소 101 번지 102 번지 변수의크기에따라 주로 byte 단위 메모리 2 기본적인변수형및변수의크기 변수의크기 해당컴퓨터에서는항상일정 컴퓨터마다다를수있음 short

More information

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D> 리눅스 오류처리하기 2007. 11. 28 안효창 라이브러리함수의오류번호얻기 errno 변수기능오류번호를저장한다. 기본형 extern int errno; 헤더파일 라이브러리함수호출에실패했을때함수예 정수값을반환하는함수 -1 반환 open 함수 포인터를반환하는함수 NULL 반환 fopen 함수 2 유닉스 / 리눅스 라이브러리함수의오류번호얻기 19-1

More information

Microsoft PowerPoint - additional01.ppt [호환 모드]

Microsoft PowerPoint - additional01.ppt [호환 모드] 1.C 기반의 C++ part 1 함수 오버로딩 (overloading) 디폴트매개변수 (default parameter) 인-라인함수 (in-line function) 이름공간 (namespace) Jong Hyuk Park 함수 Jong Hyuk Park 함수오버로딩 (overloading) 함수오버로딩 (function overloading) C++ 언어에서는같은이름을가진여러개의함수를정의가능

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Chapter 1 변수, 자료형, 예약어, 연산자, 숫자형자료형 2014. 5. 22 Python 이란? Guido Van Rossum http://www.python.org/~guido/ http://www.python.org/doc/essays/foreword/ 연구실문이닫혀있는 1989 년크리스마스기간에 무료한시간을보내기위하여새로운스크립트언어를만들게됨

More information

윈도우즈프로그래밍(1)

윈도우즈프로그래밍(1) 제어문 (2) For~Next 문 윈도우즈프로그래밍 (1) ( 신흥대학교컴퓨터정보계열 ) 2/17 Contents 학습목표 프로그램에서주어진특정문장을부분을일정횟수만큼반복해서실행하는문장으로 For~Next 문등의구조를이해하고활용할수있다. 내용 For~Next 문 다중 For 문 3/17 제어문 - FOR 문 반복문 : 프로그램에서주어진특정문장들을일정한횟수만큼반복해서실행하는문장

More information

PowerPoint Presentation

PowerPoint Presentation Package Class 1 Heeseung Jo 목차 section 1 패키지개요와패키지의사용 section 2 java.lang 패키지의개요 section 3 Object 클래스 section 4 포장 (Wrapper) 클래스 section 5 문자열의개요 section 6 String 클래스 section 7 StringBuffer 클래스 section

More information

No Slide Title

No Slide Title Copyright, 2001 Multimedia Lab., CH 3. COM object (In-process server) Eun-sung Lee twoss@mmlab.net Multimedia Lab. Dept. of Electrical and Computer Eng. University of Seoul Seoul, Korea 0. Contents 1.

More information

Microsoft PowerPoint - [2009] 02.pptx

Microsoft PowerPoint - [2009] 02.pptx 원시데이터유형과연산 원시데이터유형과연산 원시데이터유형과연산 숫자데이터유형 - 숫자데이터유형 원시데이터유형과연산 표준입출력함수 - printf 문 가장기본적인출력함수. (stdio.h) 문법 ) printf( Test printf. a = %d \n, a); printf( %d, %f, %c \n, a, b, c); #include #include

More information

4장.문장

4장.문장 문장 1 배정문 혼합문 제어문 조건문반복문분기문 표준입출력 입출력 형식화된출력 [2/33] ANSI C 언어와유사 문장의종류 [3/33] 값을변수에저장하는데사용 형태 : < 변수 > = < 식 > ; remainder = dividend % divisor; i = j = k = 0; x *= y; 형변환 광역화 (widening) 형변환 : 컴파일러에의해자동적으로변환

More information

Design Issues

Design Issues 11 COMPUTER PROGRAMMING INHERIATANCE CONTENTS OVERVIEW OF INHERITANCE INHERITANCE OF MEMBER VARIABLE RESERVED WORD SUPER METHOD INHERITANCE and OVERRIDING INHERITANCE and CONSTRUCTOR 2 Overview of Inheritance

More information

쉽게 풀어쓴 C 프로그래밍

쉽게 풀어쓴 C 프로그래밍 객체지향프로그래밍 (OOP: object-oriented programming) 은우리가살고있는실제세계가객체 (object) 들로구성되어있는것과비슷하게, 소프트웨어도객체로구성하는방법이다. 객체는상태와동작을가지고있다. 객체의상태 (state) 는객체의속성이다. 객체의동작 (behavior) 은객체가취할수있는동작 ( 기능 ) 이다. 객체에대한설계도를클래스 (class)

More information

Infinity(∞) Strategy

Infinity(∞) Strategy 반복제어 표월성 passwd74@cherub.sungkyul.edu 개요 for() 문 break문과 continue문 while문 do-while문 for() 문 for() 문형식 for( 표현식1; 표현식2; 표현식3) 여러문장들 ; 표현식 1 : 초기화 (1 번만수행 ) 표현식 2 : 반복문수행조건 ( 없으면무한반복 ) 표현식 3 : 반복문수행횟수 for()

More information

Python과 함께 배우는 시스템 해석 - 부록 A.과학계산용 Python 프로그래밍 기초 A-1. Python 프로그래밍 기초

Python과 함께 배우는 시스템 해석 -    부록 A.과학계산용 Python 프로그래밍 기초   A-1. Python 프로그래밍 기초 부록 A.과학계산용 프로그래밍 기초 A-1. 프로그래밍 기초 한림대학교 전자공학과 2014년 9월 배울 내용 소개 기본 문법 함수 논리식 모듈 한림대학교 제 2 강 프로그래밍 기초 2 신호 및 시스템과 신호와 을 효율적으로 공부하기 위해서는 다양한 기능을 지원할 수 있는 소프트웨어를 잘 활용하는 것이 중요 수열 또는 수식으로 표현되는 신호에 다양한 연산 필요

More information

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션 Chapter 08 함수 01 함수의개요 02 함수사용하기 03 함수와배열 04 재귀함수 함수의필요성을인식한다. 함수를정의, 선언, 호출하는방법을알아본다. 배열을함수의인자로전달하는방법과사용시장점을알아본다. 재귀호출로해결할수있는문제의특징과해결방법을알아본다. 1.1 함수의정의와기능 함수 (function) 특별한기능을수행하는것 여러가지함수의예 Page 4 1.2

More information

학습목표 함수프로시저, 서브프로시저의의미를안다. 매개변수전달방식을학습한다. 함수를이용한프로그래밍한다. 2

학습목표 함수프로시저, 서브프로시저의의미를안다. 매개변수전달방식을학습한다. 함수를이용한프로그래밍한다. 2 학습목표 함수프로시저, 서브프로시저의의미를안다. 매개변수전달방식을학습한다. 함수를이용한프로그래밍한다. 2 6.1 함수프로시저 6.2 서브프로시저 6.3 매개변수의전달방식 6.4 함수를이용한프로그래밍 3 프로시저 (Procedure) 프로시저 (Procedure) 란무엇인가? 논리적으로묶여있는하나의처리단위 내장프로시저 이벤트프로시저, 속성프로시저, 메서드, 비주얼베이직내장함수등

More information

Microsoft PowerPoint - chap13-입출력라이브러리.pptx

Microsoft PowerPoint - chap13-입출력라이브러리.pptx #include int main(void) int num; printf( Please enter an integer: "); scanf("%d", &num); if ( num < 0 ) printf("is negative.\n"); printf("num = %d\n", num); return 0; 1 학습목표 스트림의 기본 개념을 알아보고,

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 클래스, 객체, 메소드 손시운 ssw5176@kangwon.ac.kr 실제세계는객체로이루어진다. 2 객체와메시지 3 객체지향이란? 실제세계를모델링하여소프트웨어를개발하는방법 4 객체 5 객체란? 객체 (Object) 는상태와동작을가지고있다. 객체의상태 (state) 는객체의특징값 ( 속성 ) 이다. 객체의동작 (behavior) 또는행동은객체가취할수있는동작

More information

PowerPoint Presentation

PowerPoint Presentation 객체지향프로그래밍 오류처리 손시운 ssw5176@kangwon.ac.kr 오류메시지를분석한다. 오류메시지에서많은내용을알수있다. 2 디버깅 디버거를사용하면프로그램에서쉽게오류를감지하고진단할수있다. 디버거는중단점을설정하여서프로그램의실행을제어할수있으며문장 단위로실행하거나변수의값을살펴볼수있다. 3 이클립스에서디버깅 4 이클립스에서디버깅 5 이클립스의디버깅명령어 6 예외처리

More information

PowerPoint Presentation

PowerPoint Presentation 자바프로그래밍 1 배열 손시운 ssw5176@kangwon.ac.kr 배열이필요한이유 예를들어서학생이 10 명이있고성적의평균을계산한다고가정하자. 학생 이 10 명이므로 10 개의변수가필요하다. int s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; 하지만만약학생이 100 명이라면어떻게해야하는가? int s0, s1, s2, s3, s4,

More information

14장 파일

14장 파일 14 장파일 박창이 서울시립대학교통계학과 박창이 ( 서울시립대학교통계학과 ) 14 장파일 1 / 22 학습내용 파일입출력예포멧연산자 (format operator) 파일명과경로예외처리하기피클링 (pickling) 파일입출력디버깅 박창이 ( 서울시립대학교통계학과 ) 14 장파일 2 / 22 파일입출력예 >>> fout = open( output.txt, w )

More information

ORANGE FOR ORACLE V4.0 INSTALLATION GUIDE (Online Upgrade) ORANGE CONFIGURATION ADMIN O

ORANGE FOR ORACLE V4.0 INSTALLATION GUIDE (Online Upgrade) ORANGE CONFIGURATION ADMIN O Orange for ORACLE V4.0 Installation Guide ORANGE FOR ORACLE V4.0 INSTALLATION GUIDE...1 1....2 1.1...2 1.2...2 1.2.1...2 1.2.2 (Online Upgrade)...11 1.3 ORANGE CONFIGURATION ADMIN...12 1.3.1 Orange Configuration

More information

2013 <D55C><ACBD><C5F0><BC31><C11C>(<CD5C><C885>).pdf

2013 <D55C><ACBD><C5F0><BC31><C11C>(<CD5C><C885>).pdf 2013 ANNUAL REPORT Contents 006 007 007 008 009 Part 1 016 017 018 019 020 021 022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 Part 2 048 049 050 051 052 053

More information