Skip to content

Instantly share code, notes, and snippets.

View jennyonjourney's full-sized avatar

Kyungeun, Jeon (Jenny) jennyonjourney

View GitHub Profile
@jennyonjourney
jennyonjourney / gist:b01fd37fcc018c7e6dd319241bee1489
Created March 25, 2018 09:08
Python - copyree_movetree + 외장함수os
import shutil
shutil.copy('../fff/Chicago.jpg','../mmm/image2.jpg')
#시카고 이미지를 mmm폴더의 imgage2로 저장하겠다.
shutil.move('../mmm/image2.jpg','../fff/Chicago2.jpg')
#mmm폴더의 image2를 다시 fff폴더에 Chicago2이름으로 이동
--------------------------------------------------------
@jennyonjourney
jennyonjourney / gist:e3a7b0ef56b782bd01eede01706cf9a3
Created March 25, 2018 06:28
Python - file read/readline/readlines()
#readline()함수
#한글을 읽으려면 꼭 utf-8을 잊지말자.
fa=open('../fff/aaa.txt','r', encoding='utf-8')
dd=fa.read()
fa.close()
print(dd)
#한글을 읽으려면 꼭 utf-8을 잊지말자.
fa=open('../fff/stud.csv','r')
# ../는 이걸 나가겠다. 뜻임
# 줄을 바꾸고 싶다면 역슬러쉬를 항상 그어줘야 한다.
f = open('../fff/aaa.txt','w')
f.write('query')
f.write('aaa')
f.write('bbb\n')
f.write('ccc')
f.close()
# 한글이 안깨졌으면 좋겠다. 기본이 utf-8이다.
@jennyonjourney
jennyonjourney / gist:e4982d3fedd6c70f1da239f86f1918b7
Created March 25, 2018 03:19
Python for everybody - Assignment 4.6
def computepay(h,r):
if h<=40:
pay=h*r
elif h>40:
pay=40*r+(h-40)*r*1.5
return(pay)
hrs = input("Enter Hours:")
h = float(hrs)
rate = input("Enter rate:")
@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:
@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 / gist:32f7e513127c4d9152f27708aed474a2
Created March 25, 2018 02:03
Python basic - exam if/else 활용하기
score=78
if score>=80:
pass
print("의사소견:", '뇌는 있네')
print('없는 줄 알았잖아')
IQ = '동물수준'
result = '우수라고 해줄게'
else:
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)
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)
@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: