Skip to content

Instantly share code, notes, and snippets.

View jennyonjourney's full-sized avatar

Kyungeun, Jeon (Jenny) jennyonjourney

View GitHub Profile
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)
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)
hap=0
i = 0 #초기값
while i <= 10:
print("아기 상어", i)
hap+=i #hap에 계속 누적을 하는 것이다.
i+=1 #증감
print(hap)
#0~200까지 3의 배수들의 합
i=0
while True:
if i==10:
break #딱 10일때 정확히 stop되고, 더이상 프린터를 하지 않는다.
print("아기 상어",i)
i+=1
print("종료")
print('-----input-------')
@jennyonjourney
jennyonjourney / gist:5388b0d01d140607d7a3c647a5e26366
Created March 25, 2018 01:52
Python - continue & whilewhile
i=0
while i<10:
print("시작:", i)
i += 1
if i==5:
continue
print("끝:", i)
i=0
while i<10:
ff = "911117-2360600"
year = int(ff[:2]) #91
gender = int(ff[8]) #2
country = int(ff[9:11]) #60
result1 = '1990년대' if year<=99 else '2000년대'
result2 = '여자' if not gender%2 else '남자'
result3 = '내국인' if country<=90 else '외국인'
print('판단:', result1, result2, result3)
x=17
y=7
print(x+y)
print(x-y)
print(x/y)
print(x**y)
print(x//y)
print(x%y)
print(1==3)
@jennyonjourney
jennyonjourney / gist:32f7e513127c4d9152f27708aed474a2
Created March 25, 2018 02:03
Python basic - exam if/else 활용하기
score=78
if score>=80:
pass
print("의사소견:", '뇌는 있네')
print('없는 줄 알았잖아')
IQ = '동물수준'
result = '우수라고 해줄게'
else:
@jennyonjourney
jennyonjourney / gist:918922445d222040c790e2d7b9278b76
Created March 25, 2018 02:03
Python - exam 수우미양가 매기기
#평균이 90점이상인 경우에만 '수'
#모든 과목이 90점이상이라면 수 옆에 초우등생
name = "샛별"
kor = 91
eng = 81
mat = 95
sum = kor+eng+mat
avg = sum/3
result = '수' if avg >= 90 else '우' \
@jennyonjourney
jennyonjourney / Write a program to prompt for score..
Created March 25, 2018 02:41
Python for everybody - Assignment3.3
score = input("Enter Score: ")
try:
s=float(score)
except:
print('error')
quit()
if s>=0.9:
print('A')
elif s>=0.8: