(一)Python入门:06海龟绘图-坐标系问题-画笔各种方法
一:开始学习图形化程序设计
1 >>> import turtle #导入turtle 模块 2 >>> turtle.showturtle() #显示箭头 3 >>> turtle.write("python") #写字符串 4 >>> turtle.forward(300) #前进 300 像素 5 >>> turtle.color("red") #画笔颜色改为red 6 >>> turtle.left(90) #箭头左转 90 度 7 >>> turtle.forward(300) 8 >>> turtle.goto(0,50) #去坐标(0,50) 9 >>> turtle.goto(0,0) 10 >>> turtle.penup() #抬笔。这样,路径就不会画出来 11 >>> turtle.goto(0,300) 12 >>> turtle.pendown() #下笔。这样,路径就会画出来 13 >>> turtle.circle(100) #画圆
二:绘制奥运五环标记
1 import turtle 2 3 turtle.width(10) 4 5 turtle.color("blue") 6 turtle.circle(50) 7 8 turtle.penup() 9 turtle.goto(120,0) 10 turtle.color("black") 11 turtle.pendown() 12 turtle.circle(50) 13 14 turtle.penup() 15 turtle.goto(240,0) 16 turtle.color("red") 17 turtle.pendown() 18 turtle.circle(50) 19 20 turtle.penup() 21 turtle.goto(60,-50) 22 turtle.color("yellow") 23 turtle.pendown() 24 turtle.circle(50) 25 26 turtle.penup() 27 turtle.goto(180,-50) 28 turtle.color("green") 29 turtle.pendown() 30 turtle.circle(50)
运行结果:
posted on 2019-05-11 23:22 JACK#zhang 阅读(5501) 评论(0) 编辑 收藏 举报