컴퓨터 프로그램

컴퓨터가 수행할 명령어를 적어 놓은 문서

어떤 문제를 해결하기 위해 컴퓨터에게 주어지는 처리 방법과 순서를 기술한 일련의 명령문 집합체

프로그래머

프로그램을 만드는 사람

IDLE

파이썬 코드를 작성하고 실행하고 저장하고 불러오는 것을 쉽게 해주는 것이 IDLE(Integrated Development and Learning Environment)다. 이 책의 코드를 작성하고 실행하는 것은 IDLE만으로도 충분할 것으로 생각 된다. 조금 인터넷을 검색해보면 '파이참' 또는 '주피터 노트북'이라는 통합개발환경 툴이 있다. 어느 것이든 한번쯤 사용해 보는걸 추천 하고, 툴 설치 사용에 서투르다면 나중에 해보길 바란다.

turtle

아마도 이 책을 혼자 공부를 한다면, 처음부터 막막할거 같다. 변수나 객체에 대한 얘기가 없기에 뭔지 모를거 같지만, 그냥 따라하면 된다. 어자피 앞으로 자세하게 배울테니까. 그리고 기존의 코드를 살짝 바꿔주고 결과가 어떻게 표시되는지 여러번 확인 하면, 정확하게는 아니더라도 대충은 어떻게 사용하는지는 알게 된다. 


1
2
3
4
5
6
7
>>> import turtle
>>> han = turtle.Turtle()
>>> han.shape('turtle')
>>> han.shape('turtle')
>>> han.forward(100)
>>> han.right(90)
>>> han.forward(100)
cs


이 코드를 하나씩 실행하게 되면 

화면이 하나 생기면서 

가운데 화살표가 표시 된다. 

그리고 화살표가 거북이로 변경 되고,

거북이가 보는 방향으로 100만큼 이동하면서 선이 그려진다.

그리고 시계방향으로 90도 거북이가 회전하고

거북이가 보는 방향으로 100만큼 이동하면서 선이 그려진다.


여러번 해본다면 어렵지 않게 자연스럽게  선을 그릴 수 있다.


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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
>>> dir(turtle)
['Canvas''Pen''RawPen''RawTurtle''Screen''ScrolledCanvas''Shape''TK''TNavigator'
'TPen''Tbuffer''Terminator''Turtle''TurtleGraphicsError''TurtleScreen''TurtleScreenBase'
'Vec2D''_CFG''_LANGUAGE''_Root''_Screen''_TurtleImage''__all__''__builtins__''__cached__'
'__doc__''__file__''__forwardmethods''__func_body''__loader__''__methodDict''__methods'
'__name__''__package__''__spec__''__stringBody''_alias_list''_make_global_funcs'
'_screen_docrevise''_tg_classes''_tg_screen_functions''_tg_turtle_functions''_tg_utilities'
'_turtle_docrevise''_ver''addshape''back''backward''begin_fill''begin_poly''bgcolor''bgpic'
'bk''bye''circle''clear''clearscreen''clearstamp''clearstamps''clone''color''colormode'
'config_dict''deepcopy''degrees''delay''distance''done''dot''down''end_fill''end_poly'
'exitonclick''fd''fillcolor''filling''forward''get_poly''get_shapepoly''getcanvas'
'getmethparlist''getpen''getscreen''getshapes''getturtle''goto''heading''hideturtle''home'
'ht''inspect''isdown''isfile''isvisible''join''left''listen''lt''mainloop''math''mode'
'numinput''onclick''ondrag''onkey''onkeypress''onkeyrelease''onrelease''onscreenclick''ontimer'
'pd''pen''pencolor''pendown''pensize''penup''pos''position''pu''radians''read_docstrings'
'readconfig''register_shape''reset''resetscreen''resizemode''right''rt''screensize''seth'
'setheading''setpos''setposition''settiltangle''setundobuffer''setup''setworldcoordinates''setx'
'sety''shape''shapesize''shapetransform''shearfactor''showturtle''simpledialog''speed'
'split''st''stamp''sys''textinput''tilt''tiltangle''time''title''towards''tracer'
'turtles''turtlesize''types''undo''undobufferentries''up''update''width''window_height'
'window_width''write''write_docstringdict''xcor''ycor']
>>> dir(turtle.Turtle)
['DEFAULT_ANGLEOFFSET''DEFAULT_ANGLEORIENT''DEFAULT_MODE''START_ORIENTATION''__class__''__delattr__'
'__dict__''__dir__''__doc__''__eq__''__format__''__ge__''__getattribute__''__gt__''__hash__'
'__init__''__init_subclass__''__le__''__lt__''__module__''__ne__''__new__''__reduce__'
'__reduce_ex__''__repr__''__setattr__''__sizeof__''__str__''__subclasshook__''__weakref__'
'_cc''_clear''_clearstamp''_color''_colorstr''_delay''_drawturtle''_getshapepoly''_go'
'_goto''_newLine''_pen''_polytrafo''_reset''_rotate''_screen''_setDegreesPerAU''_setmode'
'_tracer''_undo''_undogoto''_update''_update_data''_write''back''backward''begin_fill''begin_poly'
'bk''circle''clear''clearstamp''clearstamps''clone''color''degrees''distance''dot''down'
'end_fill''end_poly''fd''fillcolor''filling''forward''get_poly''get_shapepoly''getpen''getscreen'
'getturtle''goto''heading''hideturtle''home''ht''isdown''isvisible''left''lt'
'onclick''ondrag''onrelease''pd''pen''pencolor''pendown''pensize''penup''pos''position'
'pu''radians''reset''resizemode''right''rt''screens''seth''setheading''setpos''setposition'
'settiltangle''setundobuffer''setx''sety''shape''shapesize''shapetransform''shearfactor''showturtle'
'speed''st''stamp''tilt''tiltangle''towards''turtlesize''undo''undobufferentries''up''width'
'write''xcor''ycor']
>>> help(turtle.Turtle.forward)
Help on function forward in module turtle:
 
forward(self, distance)
    Move the turtle forward by the specified distance.
    
    Aliases: forward | fd
    
    Argument:
    distance -- a number (integer or float)
    
    Move the turtle forward by the specified distance, in the direction
    the turtle is headed.
    
    Example (for a Turtle instance named turtle):
    >>> turtle.position()
    (0.000.00)
    >>> turtle.forward(25)
    >>> turtle.position()
    (25.00,0.00)
    >>> turtle.forward(-75)
    >>> turtle.position()
    (-50.00,0.00)
 
>>> help(han.forward)
Help on method forward in module turtle:
 
forward(distance) method of turtle.Turtle instance
    Move the turtle forward by the specified distance.
    
    Aliases: forward | fd
    
    Argument:
    distance -- a number (integer or float)
    
    Move the turtle forward by the specified distance, in the direction
    the turtle is headed.
    
    Example (for a Turtle instance named turtle):
    >>> turtle.position()
    (0.000.00)
    >>> turtle.forward(25)
    >>> turtle.position()
    (25.00,0.00)
    >>> turtle.forward(-75)
    >>> turtle.position()
    (-50.00,0.00)
 
>>> 
cs


help와 dir 내장함수를 이용하여 우리가 사용하는 것(?)에 대하여 정보를 얻을 수 있다.

반응형
블로그 이미지

두리뭉실:해피파인더그룹

컴퓨터 코치 두리뭉실

,