문제풀이(2)
-
중급 파이썬 문제풀이 Part 5 - 텍스트파일
텍스트 파일 읽기/쓰기 프로그래밍 # 65강. 회원 계정별 텍스트 파일을 생성한 후 회원 본인 파일에 '한 줄 일기'를 쓰고 읽는 프로그램을 만들어 보자. diary.py import time def writeDiary(u, f, d): lt = time.localtime() timeStr = time.strftime('%Y-%m-%d %I:%M:%S %p', lt) filePath = u + f with open(filePath, 'a') as f: f.write(f'[{timeStr}] {d}\n') def readDiary(u, f): lt = time.localtime() timeStr = time.strftime('%Y-%m-%d %I:%M:%S %p', lt) filePath = u + f d..
2023.03.16 -
중급 파이썬 문제풀이 Part 2 - 모듈
#46. 과목별 점수를 입력하면 합격 여부를 출력하는 모듈을 만들어보자. (평균 60 이상 합격, 과락 40으로 한다.) def exampleResult(s1,s2,s3,s4,s5): pass_avg_score = 60; limit_score = 40 def get_total(): total_score = s1 + s2 + s3 + s4 + s5 print(f'총점 : {total_score}') return total_score def get_average(): avg = get_total() / 5 print(f'평균 : {avg}') return avg def print_pass_or_fail(): print(f'{s1}: Pass ') if s1 >= limit_score else print(f'..
2023.03.16