본문 바로가기

python45

예시로 배우는 파이썬 (WITH) ############################################################################## Python 기초 12 : with# eplus(www.eiot.co.kr)-나도코딩(YouTube):파이썬 코딩 무료 강의 (기본편) 참조 ############################################################################# with open("study.txt", "w", encoding = "utf8") as s_file: s_file.write("파이썬은 GOOD!") with open("study.txt", "r", encoding = "utf8") as s_file: print(s_file.read().. 2024. 10. 15.
예시로 배우는 파이썬 (pickle) ############################################################################## Python 기초 12 : pickle# eplus(www.eiot.co.kr)-나도코딩(YouTube):파이썬 코딩 무료 강의 (기본편) 참조 #############################################################################import pickle p_file = open("profile.pickle", "wb")profile = {"이름":"박명수", "나이":30, "취미":{"축구", "골푸", "코딩"}}print(profile) pickle.dump(profile, p_file)p_file.clos.. 2024. 10. 14.
ChatGPT Canvas로 5분만에 만든 게임 # pip install pygameimport pygame import time import random # 초기화 pygame.init() # 색상 정의 white = (255, 255, 255)  # 배경 색상 black = (0, 0, 0)  # 뱀 색상 red = (213, 50, 80)  # 게임 종료 메시지 색상 green = (0, 255, 0)  # 먹이 색상 blue = (50, 153, 213)  # 점수 색상 # 화면 크기 설정 width = 600 height = 400 display = pygame.display.set_mode((width, height))  # 게임 화면 생성 pygame.display.set_caption('Snake Game')  # 게임 제목 설정 clo.. 2024. 10. 13.
예시로 배우는 파이썬 (제어문-while) ############################ Python 기초 8 : 제어문 - while # eplus(http://www.eiot.co.kr)-나도코딩(YouTube):파이썬 코딩 무료 강의 (기본편) 참조 ############################ 제어문 c = "토르" i = 5 while i >= 1:     print("{0}, 커피가 준비되었습니다. {1}".format(c, i))     i -=1     if i == 0:     print("폐기" ) i = 1 while True:     print("{0}, 커피가 준비되었습니다. {1}".format(c, i))     i += 1     if i ==2:     break c = "강" p = "Unknown" w.. 2024. 10. 7.
예시로 배우는 파이썬 (제어문-for) ######################## # Python 기초 8 : 제어문 # eplus(http://www.eiot.co.kr)-나도코딩(YouTube):파이썬 코딩 무료 강의 (기본편) 참조 ######################## # 제어문 for w in [1,2,3,4] :     print(" W : " , w) for w in (range(1, 5)):     print(" R : ", w) st = ["A","B"] print(st, type(st)) for s in st: print(s) 2024. 10. 7.
예시로 배우는 파이썬 (입력 - INPUT) ################################ # Python 기초 7 : 입력문 # eplus(http://www.eiot.co.kr)-나도코딩(YouTube):파이썬 코딩 무료 강의 (기본편) 참조 ################################ weather = input("오늘 날씨는?") if weather == "비" or weather == "눈":     print("우산을 챙기세요") elif weather == "미세먼지":     print("마스크를 챙기세요") else:     print("준비물 필요 없어요") temp = int(input("기온은 어때요?")) if temp >= 30:     print("너무 더워요") elif temp > 10 an.. 2024. 10. 7.
728x90
반응형