Advertisement
cmass

소프트웨어 교육론 p442

Feb 18th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. import turtle
  2. t=turtle.Turtle()
  3. t.shape('turtle')
  4.                        
  5. age=['0-14세','15-64세', '65세이상']
  6. data=[66, 375, 73]
  7. def go(x,y):                      
  8.     t.pu()
  9.     t.goto(x,y)
  10.     t.pd()
  11. def bar(size):
  12.     t.begin_fill()
  13.     t.fd(size); t.lt(90)
  14.     t.fd(30); t.lt(90)
  15.     t.fd(size); t.lt(90)
  16.     t.fd(30); t.lt(90)
  17.     t.end_fill()
  18. t.color('black')
  19. go(30,100)
  20. t.write("연령별 인구수", align = "center", font=("Malgun Gothic", 25, "bold"))
  21. x=-150; y=0
  22. go(x,y)
  23. for i in range(3):                #연령 구분
  24.     t.write(age[i], align = "right", font=("Malgun Gothic", 15, "bold"))
  25.     y=y-50
  26.     go(-150,y)
  27. t.color('blue')
  28. x=-100; y=0
  29. go(x,y)
  30. for i in range(3):               # 막대그래프 그리기
  31.     bar(data[i])
  32.     y=y-50                       # 막대 간격 이동
  33.     go(-100,y)
  34. t.ht()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement