This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fn1(arr): | |
hap=0 | |
for i in arr: | |
hap+=1 | |
print("fn1()",arr,hap) | |
fn1([11,22,33,44]) | |
# 이렇게 튜플이 아니면 넣을수 없다 -> fn1(11,22,33,44) | |
# 열거형은 맨 뒤에서 온다. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr1 = [11,22,33,44] | |
a = 10 | |
b = a | |
print("a:", id(a)) | |
print("b:", id(b)) | |
a = 20 | |
print("a:", id(a)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dic2 = {'키':157, | |
'나이':26, | |
'이름':'이은혜', | |
'성별':'여자'} | |
print(dic2) | |
print(dic2['나이']) | |
dic2 = {'키':157, | |
'나이':26, | |
'이름':'이은혜', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fn1(): #매개변수x,리턴x | |
print("fn1()") | |
def fn2(a,b,c): #매개변수o,리턴x | |
print("fn2():", a,b,c, a+b+c) | |
def fn3(): #매개변수x,리턴o | |
print("fn3():") | |
return 100, 200, 300 | |
def fn4(a,b): | |
print("fn4():", a, b) | |
return a*b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cumsum(num): | |
res=0 | |
for i in range(num+1): | |
res+=i | |
return res | |
print(cumsum(10)) | |
print(cumsum(20)) | |
print(cumsum(30)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fn1(aa,bb): #매개변수 | |
a=77 | |
bb= 3333 | |
cc= 100 #지역변수 | |
print("fn1:", aa,bb,cc,a) | |
def fn2(): | |
global a | |
a = 9999 | |
print("fn2():",a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rate = (0.5, 0.3, 0.2) #국어 수학 영어 점수의 반영율 | |
def studcal(st): | |
jum = 0 | |
for i in range(len(rate)): | |
jum+=st[i+1]*rate[i] | |
print(jum) | |
st1 = ['김고은', 77,88,91] | |
st2 = ['이효은', 81,92,100] | |
st3 = ['박장환', 91,76,82] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ppp="" | |
def fn1(): | |
global ppp | |
pre = ppp | |
ppp+="\t" | |
a=10 | |
print(pre+"fn1() 시작",a) | |
fn2(); | |
print(pre+"fn1() 끝",a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hit = [22,24,25,27,21,22,23,25,27,22,24,27,22] | |
hh = {} | |
# i번째가 아니라 hit의 'i'key라는 의미 | |
# hh[i]는 hh의 딕셔너리의 i key라는 의미 | |
# cnt 1 인상태인데 만약 i가 hh안에 있으면 cnt더하세요, 카운트 수가 올라가겠지. | |
for i in hit: | |
cnt = 1 | |
if i in hh: | |
cnt += hh[i] | |
hh[i] = cnt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hit = [22,24,25,27,21,22,23,25,27,22,24,27,22] | |
hh = {} | |
# i번째가 아니라 hit의 'i'key라는 의미 | |
# hh[i]는 hh의 딕셔너리의 i key라는 의미 | |
# cnt 1 인상태인데 만약 i가 hh안에 있으면 cnt더하세요, 카운트 수가 올라가겠지. | |
for i in hit: | |
cnt = 1 | |
if i in hh: | |
cnt += hh[i] | |
hh[i] = cnt |
OlderNewer