Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- DataFrame
- Python
- Boxplot
- 대치법
- 이상치
- 보간법
- subplots
- SimpleImputer
- 데이터프레임
- MSE
- KoNLP
- koNLPy
- 불용어
- BDA
- IterativeImputer
- stopwords
- 선형보간
- 전처리
- 누락값
- Outlier
- join
- value_counts
- interpolate
- sklearn
- countplot
- 결측치대체
- matplotlib
- 결측치
- Seaborn
- 파이썬
Archives
- Today
- Total
ACAIT
[Python] 221026_조건문, 반복문, 사용자 정의 함수, 파일 읽고 쓰기 복습 본문
password = 'data'
answer = input('비밀번호를 입력해 주세요: ')
if password == answer:
print('correct')
num = int(input('숫자를 입력해 주세요 : '))
if num <0:
print('0보다 큰 숫자를 입력해 주세요')
else:
if num%2==0:
print('짝')
else:
print('홀')
score = int(input('점수: '))
if score >= 90:
print('a')
elif score >= 80:
print('b')
else:
print('f')
answer = input('통신사 : ').upper()
telecom = 0
tel3 = ['SKT','SK','SK텔레콤','SK 텔레콤','KT','LG', 'LG U+', 'LG 유플러스']
if answer in tel3:
if answer in (tel3[0:3]):
telecom = 'SK 텔레콤'
elif answer in (tel3[5:7]):
telecom = 'LG U+'
else:
telecom = 'KT'
print('고객님 통신사는 %s 입니다.'%telecom)
else:
print('오류')
age = int(input('연령: '))
ten = 0
if age >= 60:
ten = '60대 이상'
elif age >= 50:
ten = '50대'
elif age >= 40:
ten = '40대'
else:
ten = '30대 이하'
print('고객님 연령대는 %s 입니다.'%ten)
total = 1
for i in range(1,8):
total *= i
print(total)
total = 1
i = 1
while i<=7:
total*=i
i+=1
print(total)
num = int(input('구구단 : '))
for i in range(2,10):
print('%d x %d = %d'%(num,i,num*i))
num = int(input("구구단?: "))
i = 1
while i<=9:
print("%d x %d = %d"%(num,i,num*i))
i+=1
for i in range(2,10):
for j in range(1,10):
print("%d x %d = %d"%(i,j,i*j))
i =2
j =1
while i<=9:
while j<=9:
print('%d x %d = %d'%(i,j,i*j))
j+=1
j =1
i+=1
i = 0
while i<5:
print('*'*10)
i+=1
for i in range(0,5):
print('*'*10)
money = 1000
year =0
while money <= 2000:
money*=1.07
year += 1
print('%d년'%year)
num = 0
for i in range(1,31):
if 30%i==0 and 75%i==0:
num = i
print(num)
num = 0
i = 1
while i<=30:
if 30%i==0 and 75%i==0:
num = i
i+=1
print(num)
greetings = ['안녕','니하오','헬로']
for i in greetings:
print(i)
a = ['aaaaa','bbb','ccccc']
b=[]
for i in a:
if len(i)==5:
b.append(i)
print(b)
words = {'사과':'apple','컴퓨터':'computer','책상':'desk'}
for i in words.keys():
answer = input('%s를 뜻하는 영어: '%i)
if answer == words[i]:
print('O')
else:
print('X')
scores = {'김':90, '박':95, '이':84}
sum = 0
for i in scores:
sum+= scores[i]
print('%s : %d'%(i,scores[i]))
print('합: %d, 평균: %d'%(sum, sum/len(scores)))
def tae(s):
print(s)
tae('hello')
def n_plus_1(n):
result = n+1
# return result
print(result)
# print(n_plus_1(4))
n_plus_1(4)
def make_url(str):
print('www.'+str+'.com')
make_url('naver')
def make_list(str):
print(list(str))
make_list('naver')
def make_list_no(str):
a = []
for i in list(str):
if i in a:
pass
else:
a.append(i)
print(a)
make_list_no('facebook')
def picknum(num):
a = []
for i in num:
if i % 2 == 0:
a.append(i)
print(a)
picknum([3,4,5,6,7,8])
def average(list):
result = sum(list)/len(list)
print(result)
average([0,10,20,30,40,50,60,70,80,90,100])
f = open('a.txt','r')
line = f.readline()
print(line)
f.close()
f = open('aaa.txt','r')
while 1:
line = f.readline()
if not line:
break
print(line)
f.close()
f = open('even_number.txt','r')
lines = f.readlines()
for i in lines:
print(i)
f.close()
f = open('even_number.txt','r')
lines = f.readlines()
for i in lines:
print(i.strip())
f.close()
f = open('even_number.txt','r')
lines = f.read()
print(lines)
f.close()
f = open('even_number_221026.txt','w')
for i in range(1,31):
if i%2==0:
f.write('%s\n'%str(i))
f.close()
f = open('even_number_221026.txt','r')
read = f.read()
print(read)
f.close()
star = open('star_221026.txt','w')
for i in range(1,7):
star.write('%s\n'%('*'*i))
star.close()
star = open('star_221026.txt','a')
for i in range(1,7):
star.write('%s\n'%('*'*(7-i)))
star.close()
star = open('star_221026.txt','r')
read = star.read()
print(read)
star.close()
f1 = open('test_221026.txt','w')
f1.write('Life is too short')
f1.close()
f2 = open('test_221026.txt','r')
print(f2.read())
f2.close()
'전공 및 코드 > 데이터 마이닝(Python)' 카테고리의 다른 글
[Python] 221109_10주차 모듈, numpy, pandas (0) | 2022.11.09 |
---|---|
[Python] 221102_9주차 중간고사 코드 풀이 (0) | 2022.11.02 |
[Python] 221016_조건문, 반복문, 사용자 정의 함수, 파일 읽고 쓰기 복습 (0) | 2022.10.25 |
[Python] 221012_6주차 문자열, 사용자 정의 함수, 파일 읽기 및 쓰기 (0) | 2022.10.12 |
[Python] 221012_조건문, 반복문 복습 (0) | 2022.10.12 |