-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbigdata4.py
More file actions
350 lines (350 loc) · 4.95 KB
/
bigdata4.py
File metadata and controls
350 lines (350 loc) · 4.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# # 2p
# def sum(a, b):
# return a + b
#
# # 3p
# a = 3
# b = 4
# c = sum(a,b)
# print(c)
#
# # 5p
# def sum(a,b):
# result = a + b
# return result
# a = sum(3,4)
# print(a)
#
# # 6p
# def say():
# return 'Hi'
#
# a = say()
# print(a)
# # 7p
# def sum(a,b):
# print("%d, %d의 합은 %d입니다."%(a,b,a+b))
#
# sum(3,4)
# # 8p
# a = sum(3,4)
#
# print(a)
# # 9p
# def say():
# print('Hi')
#
# say()
#
# # 함수를 사용하는 4가지 방법이 있습니다.
# # 10p
# def sum_many(*args):
# sum = 0
# for i in args:
# sum = sum + i
# return sum
#
# sum_many(1,2,3)
# # 11p
# result = sum_many(1,2,3)
# print(result)
#
# result = sum_many(1,2,3,4,5,6,7,8,9,10)
# print(result)
#
# # 12p
# result = sum_many(1,2,3)
# print(result)
#
# result = sum_many(1,2,3,4,5,6,7,8,9,10)
# print(result)
# # 13p
# def sum_mul(choice, *args):
# if choice == "sum":
# result = 0
# for i in args:
# result = result + i
# elif choice == "mul":
# result = 1
# for i in args:
# result = result * i
# return result
#
# # 14p
# result = sum_mul('sum',1,2,3,4,5)
# print(result)
#
# result = sum_mul('mul',1,2,3,4,5)
# print(result)
#
# # 15p
#
# def sum_and_mul(a,b):
# return a+b, a*b
#
# result = sum_and_mul(3,4)
#
# result
# # 16p
# sum, mul = sum_and_mul(3,4)
#
#
# # 17p
# def sum_and_mul(a,b):
# return a+b
# return a*b
# # 두번째 리턴문은 실행되지 않음
#
# result = sum_and_mul(2,3)
# print(result)
#
# def sum_and_mul(a,b):
# return a+b
# # 따라서 이 함수와같다
#
# # 18p
# def say_nick(nick):
# if nick == "바보":
# return
# print("나의 별명은 %s입니다." %nick)
#
# # 19p
# say_nick('야호')
#
# say_nick('바보')
# # 바보라는 값이 들어오면 리턴
#
# # 20p
# def say_myself(name, old, man=True):
# print("나의 이름은 %s 입니다."% name)
# print("나이는 %d살 입니다."% old)
# if man:
# print("남자입니다.")
# else:
# print("여자입니다.")
#
# # 21p
#
# say_myself("박응용",27)
# say_myself("박응용",27,True)
#
# say_myself("박응용",27,False)
#
# # 22p
#
# def say_myself(name, man=True, old):
# print("나의 이름은 %s 입니다."% name)
# print("나이는 %d살입니다."% old)
# if man:
# print("남자입니다.")
# else:
# print("여자입니다.")
#
# say_myself("박응용",27)
#
# # 이렇게 할경우 27을 변수 둘중 어느곳에 대입해야할지 알 수 없게됨
# # 23p
#
#
# # 24p
# a = 1
# # 함수 밖의 변수 a
# # vartest 함수 선언
# def vartest(a):
# a = a +1
#
# vartest(a)
# print(a)
# # 답은 2가 아니다 이유는 함수 밖의 변수 이기 때문이다.
#
# # 25p
# #vartest_error.py
# def vartest(a):
# a=a+1
#
# vartest(3)
# print(a)
#
#
# # 26p
# a = 1
# def vartest(a):
# a = a + 1
# return a
#
# a = vartest(a)
# print(a)
#
# # 27p
# #vartest_global.py
# a = 1
# def vartest():
# global a
# a = a +1
#
# vartest()
# print(a)
#
#
# # global 가능한 사용하지 말것 리턴 사용하자
#
#
# # 28p
# a=input()
# Life is too short, you need python
#
# a
#
# # 프롬프xm 띄어서 사용자 입력 받기
#
# # 29p
#
# numbers = input("숫자를 입력하세요: ")
# print(numbers)
#
#
#
# # 30p
#
# a = 123
# print(a)
# 123
# a = “Python”
# print(a)
# Python
# a = [1, 2, 3]
# print(a)
# [1, 2, 3]
#
#
#
# # 31p
#
# print("life""is""too short")
#
# print("life"+"is"+"too short")
#
# print("life","is","too short")
#
#
#
# # 32p
#
# for i in range(10):
# print(i, end='')
#
#
#
# # 33p
#
# f = open("새파일.txt",'w')
# f.close()
#
#
#
# # 34p
#
# r 읽기 모드 – 파일을 읽기만 할 때 사용
#
# w 쓰기 모드 – 파일에 내용을 쓸 때 사용
#
# a 추가 모드 – 파일의 마지막에 새로운 내용을 추가할 때 사용
#
#
#
# # 35p
#
# f = open(“C:\python\새파일.txt", 'w')
# f.close()
#
#
#
# # 36p
#
# f = open("C:\python\새파일.txt",'w')
# for i in range(1,11):
# data = "%d번째 줄입니다.\n"%i
# f.write(data)
# f.close()
#
# 진도 여까지 나감
#
#
#
# # 37p
#
# #readline.py
# f = open("C:\python\새파일.txt",'r')
# line = f.readline()
# print(line)
# f.close()
#
#
#
# # 38p
#
# #readline_all.py
# f = open("C:\python\새파일.txt",'r')
# while True:
# line = f.readline()
# if not line: break
# print(line)
# f.close()
#
#
#
# # 39p
#
# #readlines.py
# f = open("C:\python\새파일.txt",'r')
# lines = f.readlines()
# for line in lines:
# print(line)
# f.close()
#
# # 40p
#
# #read.py
# f = open("C:\python\새파일.txt",'r')
# data = f.read()
# print(data)
# f.close()
#
#
#
# # 41p
#
# #adddata.py
# f = open("C:\python\새파일.txt",'a')
# for i in range(11,20):
# data = "%d번째 줄입니다.\n" % i
# f.write(data)
# f.close()
#
#
#
#
# # 42p
#
# f = open("foo.txt",'w')
# f.write("Life is too short, you need python")
# f.close()
#
#
# # 43p
#
#
# # 44p
#
#
#
# # 45p
#
#
# # 46p
#
#
#
#
#
#