Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import turtle
- t=turtle.Turtle()
- t.shape('turtle')
- age=['0-14세','15-64세', '65세이상']
- data=[66, 375, 73]
- def go(x,y):
- t.pu()
- t.goto(x,y)
- t.pd()
- def bar(size):
- t.begin_fill()
- t.fd(size); t.lt(90)
- t.fd(30); t.lt(90)
- t.fd(size); t.lt(90)
- t.fd(30); t.lt(90)
- t.end_fill()
- t.color('black')
- go(30,100)
- t.write("연령별 인구수", align = "center", font=("Malgun Gothic", 25, "bold"))
- x=-150; y=0
- go(x,y)
- for i in range(3): #연령 구분
- t.write(age[i], align = "right", font=("Malgun Gothic", 15, "bold"))
- y=y-50
- go(-150,y)
- t.color('blue')
- x=-100; y=0
- go(x,y)
- for i in range(3): # 막대그래프 그리기
- bar(data[i])
- y=y-50 # 막대 간격 이동
- go(-100,y)
- t.ht()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement