>>본문<<

 

오늘의 단어

abandon / acknowledge / immediate / reveal / emerge

 

 

abandon

1. 버려진, 유기된
2. 방종한, 제멋대로인

 

예문

Mortars are periodically fired from Ukrainian troops hidden in thick tree lines or abandoned gardens. He explains the Russians are just on the brow of hill in three directions.

박격포가 우크라이나 군대가 숨어있는 두꺼운 나무줄기나 버려진 공원에 주기적으로 발사된다.

 

We abandoned the picnic when it started to rain.

우리는 비가 오기 시작하자 소풍을 단념했다.

 

 

acknowledge

1. (사실로) 인정하다
2. (권위나 자격을) 인정하다
3. (편지·소포 등을) 받았음을 알리다

 

예문

Russian forces have been pushing back as recently as last night, which Ukrainian officials have now acknowledged.

러시아군이 어젯밤까지만 해도 반격했고, 우크라이나 임원들은 인정했다.

 

Did they acknowledge your letter?

그들이 당신의 편지를 받았다고 인정했나?

 

 

immediate

1. 즉각적인
2. 당면한, 목전의
3. (시간적·공간적으로) 아주 가까이에[바로 옆에] 있는

 

예문

The drugs had an immediate effect.

그 약은 즉각적인 효과가 있었다.

 

If Neskuchne is anything to go by, any liberation will be far from immediate, and won't necessarily bring freedom straight away.

만약 네스쿠흐네가 무엇이라도 한다면 어떤 해방도 목전에서 멀어지고 필연적으로 곧바로 자유를 가져다주지 못하게 될 것이다.

 

 

reveal

1. (비밀 등을) 드러내다[밝히다/폭로하다]
2. (보이지 않던 것을) 드러내 보이다

 

예문

A word count revealed that male students do not speak more than females.

단어 수를 드러내 보면 남학생들은 여학생들보다 말을 더 많이 하지 않는다.

 

The newspaper revealed that they are planning to get married.

그 신문은 그들이 결혼할 계획이라고 밝혔다.

 

 

emerge

1. (어둠 속이나 숨어 있던 곳에서) 나오다[모습을 드러내다]
2. 드러나다, 알려지다
3. 생겨나다, 부상하다, 부각되다

 

예문

A figure emerged from the shadows.

한 형상이 그림자 속에서 모습을 드러냈다.

 

Earlier this week, a video emerged purportedly showing two Ukrainian soldiers raising the country's blue-and-yellow national flag on destroyed buildings in Neskuchne.

이번 주 초, 네스쿠흐네의 부서진 건물에 두 우쿠라이나 군인의 파랑, 노랑 국기를 올리는 영상이 올라왔다.

 

 

연습문제

1. 다음 보기를 입력과 관련된 함수와 출력과 관련된 함수로 분류하세요.

input(), print(), write(), read(), readline(), writeline(), readlines()

 

더보기

답 :

입력과 관련된 함수 : input(), read(), readline(), readlines()

출력과 관련된 함수 : print(), write(), writeline()

 

2. 다음은 파일의 처리단계입니다. 순서대로 나열한 것이 맞는 것을 고르세요.

A. 파일 열기
B. 파일 쓰기
C. 파일 읽기
D. 파일 닫기

① A -> C -> B -> D

A -> C -> D -> B

D -> C -> B -> A

A -> D -> B -> C

 

더보기

답 : 1

 

3. 파일의 열기 모드에 대한 설명입니다. 거리가 먼 것을 모두 고르세요.

① 생략하면 쓰기 모드가 기본으로 설정된다.

② r+는 읽기/쓰기 겸용 모드다

a는 쓰기 모드이다. 기존 파일이 있으면 삭제하고 새로 만든다.

④ t는 텍스트 모드다.

b는 이진 파일 모드다.

⑥ tb는 텍스트 파일 겸 이진 파일 모드 공용이다.

 

더보기

답 : 1, 3, 6

해설 : 1번 생략하면 읽기 모드가 기본으로 설정된다. 3번 기존 파일을 삭제하지 않고 파일 끝에 이어서 쓴다. 6번 tb는 없는 모드이다.

 

4. 다음은 data1.txt 파일에서 1개 행만 읽어서 출력하는 코드입니다. 빈칸을 채우세요.

inFp = [     ①     ]("C:/Temp/data1.txt", "r")

inStr = inFp.[     ②     ]()
print(inStr, end = "")

inFp.[     ③     ]()

 

더보기

답 : ① open, ② readline, ③ close

 

5. 파일이 있는지 확인하는 함수를 다음 중에서 고르세요.

① os.path.file(파일명)

os.path.isfile(파일명)

os.path.place(파일명)

os.path.exists(파일명)

 

더보기

답 : 4

 

6. 다음은 파일을 복사하는 코드입니다. 빈칸을 채우세요.

inFp = open("C:/Windows/win.ini", "r")
outFp = open("C:/Temp/data3.txt", "w")

inList = [     ①     ]
for inStr in inList :
    [     ②     ]

inFp.close()
outFp.close()

 

더보기

답 : inFp.readlines(), outFp.writelines(inStr)

 

7. 글자에 대응하는 고유한 숫자를 알려주는 함수와 숫자에 해당하는 글자를 알려주는 함수의 짝으로 옳은 것을 고르세요.

① number( ), char( )

order( ), character( )

ocp( ), ch( )

ord( ), chr( )

 

더보기

답 : 4

 

8. 각 설명에 맞는 os, os.path, shutil 모듈의 함수를 쓰세요.

(1) 파일 복사

(2) 디렉터리 복사

(3) 디렉터리 생성

(4) 디렉터리 삭제

(5) 폴더 여부 확인

(6) 파일 삭제

 

더보기

답 : (1) shutil.copy, (2) shutil.copytree, (3) os.mkdir, (4) shutil.rmtree, (5) os.path.isdir, (6) os.remove

 

9. 다음 각 함수의 의미를 보기에서 고르세요.

파일 복사, 디렉터리 복사, 디렉터리 생성, 디렉터리 삭제, 폴더여부 확인, 파일 삭제

(1) shutil.rmtree( )

(2) os.path.isdir( )

(3) os.remove( )

(4) shutil.copy( )

(5) shutil.copytree( )

(6) os.mkdir( )

 

더보기

답 : (1) 디렉터리 삭제, (2) 폴더여부 확인, (3) 파일 삭제, (4) 파일 복사, (5) 디렉터리 복사, (6) 디렉터리 생성

 

10. try~except 문에서 사용하는 예외 종류를 설명한 것입니다. 예외를 쓰세요.

(1) 존재하지 않는 변수에 접근할 때

(2) 파일 처리에서 오류가 발생할 때

(3) 실행에서 오류가 발생할 때

(4) 딕셔너리에 키가 없을 때

 

더보기

답 : (1) NameError, (2) IOError, (3) RuntimeError, (4) KeyError

 

11. 다음은 파일이 없을 때 또는 0으로 나눌 때 예외 처리를 하는 코드입니다. 빈칸을 채우세요.

try :
	infp = open("c:/nofile", "r")
    value = 100 / 0
[     ①     ]:
	print("파일 입출력 오류 입니다.")
{     ②     ]:
	print("0으로 나눴습니다.")
    
print("프로그램 종료!")

 

더보기

답 : ① except IOError, ② except ZeroDivisionError

 

12. [응용예제 02]를 수정해서 다음의 기능을 구현하세요.

 ·마우스 왼쪽 버튼을 누르면 10씩 화면이 밝아진다.

 ·마우스 오른쪽 버튼을 누르면 10씩 화면이 어두워진다.

 ·마우스 가운데 버튼을 누르면 화면이 반전된다. (또 누르면 원래 화면)

 

더보기

답 :

from tkinter import *
from tkinter.filedialog import *
from tkinter.simpledialog import *
import os.path
import math

## 함수 선언 부분 ##
def  loadImage(fname) :
    global window, canvas, paper, filename, XSIZE, YSIZE, inImage, filename

    inImage=[]
    fsize = os.path.getsize(fname)              # 파일의 크기
    XSIZE = YSIZE = int(math.sqrt(fsize))      # 정방형으로 가정하고 크기 구함
    
    fp = open(fname, 'rb')   

    for i in range(0, XSIZE) :
        tmpList = []
        for k in range(0, YSIZE) :
            data = int(ord(fp.read(1)))
            tmpList.append(data)
        inImage.append(tmpList)

    fp.close()

def displayImage(image) :
    global window, canvas, paper, filename, XSIZE, YSIZE, inImage, filename
    rgbString = ""
    for i in range(0, XSIZE) :
        tmpString = ""
        for k in range(0, YSIZE) :
            data = image[i][k]
            tmpString += "#%02x%02x%02x " % (data, data, data) # x 뒤에 한칸 공백
        rgbString += "{" + tmpString +  "} " # } 뒤에 한칸 공백
    paper.put(rgbString)

def func_open() :
    global window, canvas, paper, filename, XSIZE, YSIZE, inImage, filename

    filename = askopenfilename(parent = window, filetypes = (("RAW 파일", "*.raw"),  ("모든 파일", "*.*")))
    if filename == '' : # 대화상자에서 취소를 눌렀으면
        return
    
    if canvas != None : # 기존에 열린 적이 있으면 제거
        canvas.destroy()

     # 파일 --> 메모리
    loadImage(filename)
    
    window.geometry(str(XSIZE) + 'x' + str(YSIZE)) # 윈도창 크기
    canvas = Canvas(window, height = XSIZE, width = YSIZE)
    paper = PhotoImage(width = XSIZE, height = YSIZE)
    canvas.create_image( (XSIZE / 2, YSIZE / 2), image = paper, state = "normal")
   
    # 메모리 --> 화면 
    displayImage(inImage)
    
    canvas.pack()

def func_exit() :
    window.quit()
    window.destroy()

def brightPhoto(event) :
    global window, canvas, paper, filename, XSIZE, YSIZE, inImage, filename, addValue
    addValue += 10

    for i  in range(0, XSIZE) :
        for k in range(0, YSIZE) :
            data = inImage[i][k] + addValue
            if  data > 255 :
                newData = 255
            elif data < 0 :
                newData = 0
            else :
                newData = data
            inImage[i][k] = newData

    displayImage(inImage)

def darkPhoto(event) :
    global window, canvas, paper, filename, XSIZE, YSIZE, inImage, filename, addValue
    addValue -= 10
    for i in range(0, XSIZE) :
        for k in range(0, YSIZE) :
            data = inImage[i][k] + addValue
            if  data > 255 :
                newData = 255
            elif data < 0 :
                newData = 0
            else :
                newData = data
            inImage[i][k] = newData

    displayImage(inImage)

def reversePhoto(event) :
    global window, canvas, paper, filename, XSIZE, YSIZE, inImage, filename

    for  i  in  range(0, XSIZE) :
        for  k  in  range(0, YSIZE) :
            data = inImage[i][k]
            newData = 255 - data
            inImage[i][k] = newData

    displayImage(inImage)

## 전역 변수 선언 부분 ##
window = None
canvas = None
XSIZE, YSIZE=0, 0
inImage = []    # 2차원 리스트 (메모리)
filename = '' # 파일이름 (전역 변수)
addValue = 0

## 메인 코드 부분 ##
if __name__ == "__main__" :
    window=Tk()
    window.title("연습문제")

    # 메뉴 추가
    mainMenu = Menu(window)
    window.config(menu=mainMenu)
    fileMenu = Menu(mainMenu)
    mainMenu.add_cascade(label="파일", menu=fileMenu)
    fileMenu.add_command(label="파일 열기", command=func_open)
    fileMenu.add_separator()
    fileMenu.add_command(label="프로그램 종료", command=func_exit)

    window.bind("<Button-1>", brightPhoto)
    window.bind("<Button-2>", reversePhoto)
    window.bind("<Button-3>", darkPhoto)

    window.mainloop()

 

 

*주의사항 : 제가 직접 푼 것이므로 틀린 부분이 있을 수 있습니다. 오타나 틀린 부분 지적 환영!

>>본문<<

 

오늘의 단어

gain / liberate / process / obvious / occupy

 

 

gain

1. (필요하거나 원하는 것을) 하게[얻게] 되다
2. (이익혜택을) 얻다
3. (특히 부체중의) 증가
4. 이득, 이점, 개선

 

예문

The BBC was among the first media organisations to gain access to some of the first villages liberated in Ukraine's counteroffensive.

BBC는 우크라이나의 반격으로 해방된 최초의 마을 중 하나에 접근할 수 있는 권한을 얻은 최초의 언론기관 중 하나였다.

 

Ukraine's counteroffensive is in its early stages with modest gains.

우크라이나의 공세는 초기 단계에 평범한 이득을 얻었다.

 

 

liberate

1. (국가·사람을 억압·속박으로부터) 해방시키다
2. (일상적인 제약에서) 자유롭게[벗어나게] 해주다

 

liberation

1. 해방, 석방; 해방 운동
2. 화학 유리

 

예문

Out of this cluster of four settlements in the eastern Donetsk region, Neskuchne has seen the heaviest fighting according to the battalion which liberated it.

동부 도네츠크 지역의 네 주거지 무리 중 해방된 부대인 네스쿠흐네에 따르면 가장 치열한 전투를 보았다고 한다.

 

As our army escort, Anatoliy, speeds along scarred roads in his camouflaged truck towards Neskuchne, it's clear this is a different kind of liberation to what we saw last year.

우리가 작년에 본 호위부대 아나톨리가 위장 트럭을 타고 네스쿠흐네를 향해 울퉁불퉁한 도로를 질주한 것과는 다른 종류의 해방이라는 것은 확실하다.

 

 

process

1. (특정 결과를 달성하기 위한) 과정[절차]
2. (자연스러운 변화가 일어나는) 과정
3. (원자재식품 등을) 가공[처리]하다
4. (문서요청 사항 등을 공식적으로) 처리하다

행진하다, (행진하듯이) 천천히 걷다[이동하다]

 

예문

Ukraine lost six soldiers in the process.

우크라이나는 그 과정에서 여섯 명의 군인을 잃었다.

 

Visa applications take 28 days to process.

비자 신청 처리가 28일 걸린다.

 

 

obvious

1. (눈으로 보거나 이해하기에) 분명한[명백한] (=clear)
2. (누가 생각해도) 확실한[분명한]
3. 너무 빤한

 

예문

An obvious irony for a village that was occupied by Russia in spring last year - a few weeks after President Vladimir Putin launched his full-scale invasion of Ukraine.

블라디미르 푸틴 대통령이 몇 주 후 우크라이나를 전면적으로 침략을 개시하여 작년 봄에 러시아가 마을을 점령한 것은 명백히 모순적이다.

 

It was screamingly obvious what we should do next.

우리가 무엇을 해야하는지는 극도록 확실했다.

 

The ending was pretty obvious.

결말이 너무 빤했다.

 

 

occupy

1. (공간·지역·시간을) 차지하다 (=take up)
2. 격식 (방·주택·건물을[에]) 사용하다[거주하다]
3. 점령[점거]하다

occupied

사용(되는) 중인, 바쁜, 점령된

 

예문

His book collection occupies most of the room.

그의 책 수집이 방 대부분을 차지했다.

 

Former residents of Neskuchne told the BBC that the village was also briefly occupied in 2014 - when Russia-backed fighters seized large swathes of land in the Donetsk and neighbouring Luhansk regions.

네스쿠흐네 전 주민들은 2014년 도네츠크와 근접한 루한스크지역을 러시아 지원군들이 넓게 뒤덮어 장악했을 때 잠시 점령되었다고 BBC에 말했다.

 

 

*Self Study는 공식홈페이지 자료실에 답이 나와있기 때문에 이번 글부터 따로 개시 하지 않겠습니다. 

 

연습문제

1. 다음 그림과 같은 윈도창이 나오는 코드입니다. 빈 부분을 보기에서 고르세요.

input, resizable, button, size, geometry, mainloop, title, pack, print, view
from tkinter import *

window = Tk()
window.[     ①     ]("연습 문제")
window.[     ②     ]("400x100")
window.[     ③     ](width = FALSE, height = FALSE)

label1 = Label(window, text = "COOKBOOK~~ Python을 학습중…", font = ("궁서체", 15), fg = "red")
label1.[     ④     ]();

window.[     ⑤     ]()

 

더보기

답 : ① title, ② geometry, ③ resizable, ④ pack, ⑤ mainloop

 

2. 다음은 버튼을 누르면 작동하는 코드입니다. 코드의 빈 부분에 들어갈 것을 고르세요.

*2번과 4번 항목 오탈자

from tkinter import *
from tkinter import messagebox

def click_button() :
	messagebox.showinfo("버튼", "버튼을 눌렀어요.")

window = Tk()
button1 = Button(window, text = "여기를 클릭", [          ])
button1.pack();

window.mainloop()

① command = click_button( )

② execute = click_button( )

command = click_button

execute = click_button( )

 

더보기

답 : 3번

 

3. 다음은 라디오 버튼 중 어떤 것을 클릭했는지 알려주는 코드입니다. 빈 부분에 들어갈 내용을 채우세요.

from tkinter import *
window = Tk()

def rdo_change() :
	if [     ①     ] == 1 :
		label1.configure(text = "벤츠")
	else :
		label1.configure(text = "포르쉐")
        
var = [     ②     ]
rdo1 = Radiobutton(window, text = "벤츠", variable = [     ③     ], value = 1, 이후 생략…)
rdo2 = Radiobutton(window, text = "포르쉐", variable = [     ③     ], value = 2, 이후 생략…)
label1 = Label(window, text = "선택한 차량", fg = "red")

rdo1.pack()
rdo2.pack()
label1.pack()

window.mainloop()

 

더보기

답 : ① var.get(), ② IntVar(), ③ var

 

4. 코드를 실행하면 다음 각 항에 해당하는 결과가 나오기 위해서 빈 곳에 무엇을 채워야 할지 쓰세요. (빈 칸 3곳이 모두 동일한 내용임)

from tkinter import *
window = Tk()

button1 = Button(window, text = "버튼1")
button2 = Button(window, text = "버튼2")
button3 = Button(window, text = "버튼3")

button1.pack(side = [          ])
button2.pack(side = [          ])
button3.pack(side = [          ])

window.mainloop()

(1)

(2)

(3)

(4)

더보기

답 : (1) LEFT, (2) RIGHT, (3) TOP, (4) BOTTOM

 

5. 다음은 <이전>, <다음> 버튼을 클릭하면 배열(9개 문자열)의 내용으로 글자가 바뀌는 코드입니다. 빈 부분을 채우세요. 단, 마지막 글자에서 <다음>을 클릭하면 다시 첫 번째 글자가, 첫 번째 글자에서 <이전>을 클릭하면 마지막 글자가 나오도록 하세요.

from tkinter import *
from time import *

fnameList = ["jeju1.gif", "jeju2.gif", "jeju3.gif", "jeju4.gif", "jeju5.gif", "jeju6.gif", "jeju7.gif", "jeju8.gif", "jeju9.gif"]
num = 0

def clickNext() :
    global num
         
         ①     
         
    pLabel.configure(text = fnameList[num])
    
def clickPrev() :
    global num
    
         ①
         
    pLabel.configure(text = fnameList[num])
    
window = Tk()
window.geometry("700x100")
btnPrev = Button(window, text = "<< 이전", command = clickPrev)
btnNext = Button(window, text = "다음 >>", command = clickNext)
pLabel = Label(window, text = "파일명", font = ("궁서체", 20), fg = "blue")
btnPrev.place(x = 150, y = 10)
btnNext.place(x = 500, y = 10)
pLabel.place(x = 300, y = 10)
window.mainloop()

 

더보기

답 :

num += 1
ifnum > 8 :
	num = 0
num -= 1
if num > 0 :
	num = 8

 

6. 다음은 마우스 이벤트 코드와 설명의 짝입니다. 거리가 먼 것을 모두 고르세요.

① <Button> : 모든 버튼의 공통 클릭할 때

<Button-2> : 오른쪽 버튼을 클릭할 때

<ButtonRelease-1> : 왼쪽 버튼을 떼었을 때

<ButtonDouble-1> : 왼쪽 버튼을 더블클릭할 때

<ButtonDrag-1> : 왼쪽 버튼을 드래그할 때

<Enter> : 위젯 위로 마우스 커서가 올라갈 때

 

더보기

답 : 2, 4, 5

해설 : 2번 가운데 버튼을 클릭할 때, 4번 <Double-Button-1>, 5번 <B1-Motion>

 

7. 다음은 마우스를 클릭하면 마우스의 클릭한 좌표가 메시지창으로 나오는 코드입니다. 빈 부분에 들어갈 코드를 고르세요.

 

from tkinter import *

def clickMouse(event) :
	


window = Tk()
window.geometry("400x400")
label1 = Label(window, text = "이곳이 바뀜")
window.bind("<Button>", clickMouse)
label1.pack(expand = 1, anchor = CENTER)
window.mainloop()

① txt = str(event.y) + "," + str(event.x) + "에서 클릭됨"
    window.configure(text = txt)

txt = str(mouse.y) + "," + str(mouse.x) + "에서 클릭됨"
    label1.configure(text = txt)

txt = str(event.y) + "," + str(event.x) + "에서 클릭됨"
    label1.configure(text = txt)

txt = str(event.y) + "," + str(event.x) + "에서 클릭됨"
    label1.chage(text = txt)

 

더보기

답 : 3

 

8. 다음 중 키보드 이벤트의 키가 아닌 것을 하나 고르세요.

① <Enter>

② <BackSpace>

③ <Tab>

④ <Shift_L>

<Escape>

<End>

 

더보기

답 : 1

 

9. 그림과 같은 메뉴가 나오도록 코드의 빈 부분을 채우세요.

from tkinter import *
window = Tk()
totalMenu = Menu(window)
window.config(menu = totalMenu)
upMenu = Menu(totalMenu)



window.mainloop()

 

더보기

답 :

totalMenu.add_cascade(label = "상위 메뉴", menu = upMenu)
upMenu.add_command(label = "하위메뉴1")
upMenu.add_separator()
upMenu.add_command(label = "하위메뉴2")

 

10. [프로그램 2]에 화살표 위쪽 키를 누르면 확대되고, 화살표 아래쪽 키를 누르면 축소되는 기능을 추가하세요.

힌트 PhotoImage의 확대 및 축소는 다음과 같이 함수를 활용한다.

photo = photo.zoom(확대배수, 확대배수) # 확대
photo = photo.subsample(축소배수, 축소배수) # 축소

 

 

 

더보기

답 :

from tkinter import *
from tkinter.filedialog import *

## 함수 선언 부분 ##
def func_open() :
    global photo
    filename = askopenfilename(parent = window, filetypes = (("GIF 파일", "*.gif"), ("모든 파일", "*.*")))
    photo = PhotoImage(file = filename)
    pLabel.configure(image = photo)
    pLabel.image = photo

def func_exit() :
    window.quit()
    window.destroy()

def func_zs(event) :
    if event.keycode == 38 :
        zoomphoto = photo.zoom(2, 2) # 확대
        pLabel.configure(image = zoomphoto)
        pLabel.image = zoomphoto
    elif event.keycode == 40 :
        subsamplephoto = photo.subsample(2, 2) # 축소
        pLabel.configure(image = subsamplephoto)
        pLabel.image = subsamplephoto

## 메인 코드 부분 ##
window = Tk()
window.geometry("500x500")
window.title("명화 감상하기")

photo = PhotoImage()
pLabel = Label(window, image = photo)
pLabel.pack(expand = 1, anchor = CENTER)

mainMenu = Menu(window)
window.config(menu = mainMenu)
fileMenu = Menu(mainMenu)
mainMenu.add_cascade(label = "파일", menu = fileMenu)
fileMenu.add_command(label = "파일 열기", command = func_open)
fileMenu.add_separator()
fileMenu.add_command(label = "프로그램 종료", command = func_exit)

window.bind("<Up>", func_zs)
window.bind("<Down>", func_zs)

window.mainloop()

 

 

*주의사항 : 제가 직접 푼 것이므로 틀린 부분이 있을 수 있습니다. 오타나 틀린 부분 지적 환영!

+ Recent posts