Created
March 25, 2018 02:00
-
-
Save jennyonjourney/236aee28065d2757fafe742496eb913e to your computer and use it in GitHub Desktop.
Python - slicing practice
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
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) | |
#########################선생님 답안 | |
jumin = "911117-2860600" | |
kind = int(jumin[7]) | |
print('여남'[kind%2]+'자') | |
print('한외'[kind//5]+'국민') | |
year = (kind-1)%4 | |
print(year) | |
birth = jumin[0:2]+"년"+jumin[2:4]+"월"+jumin[4:6]+"일" | |
print(birth) | |
birth = "{}{}년 {}월 {}일".format(year,jumin[0:2],jumin[2:4],jumin[4:6]) | |
print(birth) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment