본문 바로가기

프로그램659

Python 203제] 두근두근 파이썬(개정판) CHAPTER 2. p67 도전문제 출처 : 반크_반크 20년 백서 참고풀이] import webbrowser S=input("번역할 영어 문장을 입력하시오 : ") url = "https://translate.google.co.kr/#en/ko/"+S webbrowser.open(url) 참고풀이 결과] 대한민국의 아름다운 영토, 독도의 겨울 2023. 8. 1.
Python 202제] 파이썬 EXPRESS CHAPTER 9. 도전문제 p428 출처 : 반크_반크 20년 백서 참고풀이] #이 프로그램은 가위, 바위, 보 게임을 구현한다. import random from tkinter import * window = Tk() Label(window, text="선택하세요", font=("Helvetica", "16")).pack() frame = Frame(window) frame1 = Frame(window) #이미지를 본파일이 저장된 곳에 같이 있도록 하세요! rock_image = PhotoImage(file="rock.png") paper_image = PhotoImage(file="paper.png") scissors_image = PhotoImage(file="scissors.png") def pass_s(): human_image[.. 2023. 7. 17.
Python 201제] 파이썬 EXPRESS CHAPTER 9. 도전문제 p424 출처 : 반크_반크 20년 백서 참고풀이] from tkinter import * # 이벤트 처리 함수를 정의한다. def FtoC(): tf = float(e1.get()) # e1에서 문자열을 읽어서 부동소수점형으로 변경 tc = (tf-32.0)*5.0/9.0 # 화씨 온도를 섭씨 온도로 변환한다. e2.delete(0, END) # 처음부터 끝까지 지운다. e2.insert(0, str(tc)) # tc 변수의 값을 문자열로 변환하여 추가한다. def CtoF(): tc = float(e2.get()) tf = tc*9.0/5.0+32.0 e1.delete(0, END) e1.insert(0, str(tf)) window = Tk() Label(window , text="화 씨").grid(row.. 2023. 7. 10.
Python 200제] 파이썬 EXPRESS CHAPTER 9. 도전문제 p422 출처 : 반크_반크 20년 백서 참고풀이] from tkinter import * window = Tk() counter = 0 def clicked(): global counter counter += 1 label['text'] = '버튼 클릭 횟수: ' + str(counter) def Reset(): global counter counter = 0 label['text'] = '카운트가 ' + str(counter) + "으로 초기화 하였습니다." label = Label(window, text="아직 눌려지지 않음") label.pack() button = Button(window, text="증가", command=clicked).pack() button1 = Button(window, text.. 2023. 7. 10.
Python 199제] 파이썬 EXPRESS CHAPTER 9. 도전문제 p420 출처 : 반크_반크 20년 백서 참고풀이] from tkinter import * window = Tk() # 레이블 생성 Label(window, text="너 비",height=3, width=8).grid(row=0) Label(window, text="높 이",height=3, width=8).grid(row=1) # 엔트리 생성 e1 = Entry(window, width=15) e2 = Entry(window, width=15) e1.grid(row=0, column=1) e2.grid(row=1, column=1) # 이미지를 가진 레이블을 생성하여 2열과 2행에 걸쳐서 표시한다. photo = PhotoImage(file="saucer.png") label = Label(window, im.. 2023. 7. 10.
Python 198제] 파이썬 EXPRESS CHAPTER 8. Programming 9 p403 출처 : 반크_반크 20년 백서 참고풀이] import turtle def Running(r): r.forward(100) r.right(90) r.forward(20) r.left(90) r.forward(100) lee = turtle.Turtle() kim = turtle.Turtle() lee.shape("turtle") Running(lee) kim.color("blue") kim.shape("turtle") kim.left(180) Running(kim) turtle.mainloop() 참고풀이 결과] 대한민국의 아름다운 영토, 독도의 겨울 2023. 6. 12.
Python 197제] 파이썬 EXPRESS CHAPTER 8. Programming 8 p403 출처 : 반크_반크 20년 백서 참고풀이] #Song클래스를 만든다. class Song(): #생성자 함수를 생성한다. def __init__(self,songList): self.contacts = songList #Song 정보를 문자열로 변환하는 함수 def __str__(self): Str = "" for line in self.contacts: Str += line + "\n" return Str #가사를 출력하는 함수 def sing(self): for line in self.contacts: print(line) #Main 부분 aSong=Song(["TWINKLE, twinkle, little star,", "How I wonder what you are!", "Up above the w.. 2023. 6. 12.
Python 196제] 파이썬 EXPRESS CHAPTER 8. Programming 7 p402 출처 : 반크_반크 20년 백서 참고풀이] #연락처 클래스를 만든다. class Person(): #인스턴스 변수 name, mobile, office, email를 가지는 생성자 함수 def __init__(self, name, mobile=None, office=None, email=None): self.name = name self.mobile = mobile self.office = office self.email = email #Person의 정보를 문자열로 반환하는 함수 def __str__(self): Str = "" Str += self.name + "\n" if self.mobile != None: Str += "mobile phone : " + self.mobile + "\n" if s.. 2023. 6. 12.
Python 195제] 파이썬 EXPRESS CHAPTER 8. Programming 6 p402 출처 : 반크_반크 20년 백서 참고풀이] class Person: #인스턴스 변수 name, mobile, office, email를 가지는 생성자 함수 def __init__(self, n, m="01012341234", o="024251117", e="nextop@nextopedu.co.kr"): self.name=n self.mobile=m self.office=o self.email=e #Person의 정보를 문자열로 반환하는 함수 def __str__(self): Str="" Str="Person(Name=" + self.name + ", Mobile=" + self.mobile Str += ", Office=" + self.office + ", Email=" + self.email + ")".. 2023. 6. 12.
Python 194제] 파이썬 EXPRESS CHAPTER 8. Programming 5 p402 출처 : 반크_반크 20년 백서 참고풀이] class Triangle: numberOfSides=3 #인스턴스 변수 angle1, angle2, angle3를 가지는 생성자 함수 def __init__(self, a1, a2, a3): self.angle1=a1 self.angle2=a2 self.angle3=a3 #삼각형의 정보를 문자열로 반환하는 함수 def __str__(self): Str=str(self.angle1) + ", " + str(self.angle2) + ", " + str(self.angle3) Str += "세 각을 갖는 삼각형." return Str #각 속성의 설정자 함수들 def setangle1(self, a1): self.angle1=a1 def setangle1(self.. 2023. 5. 22.
Python 193제] 파이썬 EXPRESS CHAPTER 8. Programming 4 p401 출처 : 반크_반크 20년 백서 참고풀이] class Rectangle: #매개 변수 x, y, w, h를 가지는 생성자 함수 def __init__(self, x, y, w, h): self.x=x self.y=y self.width=w self.height=h #사각형의 좌표와 크기를 문자열로 반환하는 함수 def __str__(self): Str="사각형의 좌측상단 좌표(x,y) : (" + str(self.x) + ", " + str(self.y) + ")" Str+="사각형의 너비와 높이 : (" + str(self.width) + ", " + str(self.height) + ")" return Str #각 속성의 설정자 함수들 def setX(self, x): self.x=x def setY.. 2023. 5. 22.
Python 192제] 파이썬 EXPRESS CHAPTER 8. Programming 3 p401 출처 : 반크_반크 20년 백서 참고풀이] class Box: def __init__(self, l, h, d): self.length=l self.height=h self.depth=d def __str__(self): return "(" + str(self.length) + ", " + str(self.height) + ", " + str(self.depth) + ")" def setLength(self,l): self.length=l def setHeight(self,h): self.height=h def setDepth(self,d): self.depth=d def getLength(self): return self.length def getHeight(self): return self.heigh.. 2023. 5. 8.
반응형