This file contains hidden or 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
i=0 | |
while True: | |
if i==10: | |
break #딱 10일때 정확히 stop되고, 더이상 프린터를 하지 않는다. | |
print("아기 상어",i) | |
i+=1 | |
print("종료") | |
print('-----input-------') |
This file contains hidden or 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
hap=0 | |
i = 0 #초기값 | |
while i <= 10: | |
print("아기 상어", i) | |
hap+=i #hap에 계속 누적을 하는 것이다. | |
i+=1 #증감 | |
print(hap) | |
#0~200까지 3의 배수들의 합 |
This file contains hidden or 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
list1 = [11,33,22,77,11,33,77,22,11,66] | |
s1 = set(list1) | |
s2 = set((234,567,890,987,234,11,890)) | |
print(list1) | |
print(s1) | |
print(s2) | |
s2.add(22) | |
s2.update([4455,6677,1122,7788]) | |
print(s2) | |
s2.remove(6677) |
This file contains hidden or 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
s1 = set([1,2,3,4,5,6]) | |
s2 = set([4,5,6,7,8,9]) | |
uu = s1|s2 | |
ii = s1&s2 | |
mm = s1-s2 | |
uu=s1.union(s2) | |
ii=s1.intersection(s2) | |
mm=s1.difference(s2) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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)) |