赞
踩
绘制奥运五环标记
源码:
#绘制奥运五环
import turtle
turtle.width(10)
turtle.color("blue")
turtle.circle(50)
turtle.penup()
turtle.goto(120,0)
turtle.pendown()
turtle.color("black")
turtle.circle(50)
turtle.penup()
turtle.goto(240,0)
turtle.pendown()
turtle.color("red")
turtle.circle(50)
turtle.penup()
turtle.goto(60,-50)
turtle.pendown()
turtle.color("yellow")
turtle.circle(50)
turtle.penup()
turtle.goto(180,-50)
turtle.pendown()
turtle.color("green")
turtle.circle(50)
运行结果:
本章实操作业
1. 建立 Python 开发环境,并完成第一个 Python 程序。将整个过程使用图文描述出来。
2. 根据老师代码,完成奥运五环的绘图程序
3. 使用海龟绘图,输出四个矩形:
源码:
#使用海龟绘图绘制4个矩形
import turtle
turtle.showturtle() #显示箭头
#绘制4个阴影
turtle.width(4)
turtle.color("#e9e7ef") #颜色查编程颜色代码,html的颜色代码通用
turtle.penup()
turtle.goto(5,-5)
turtle.pendown()
turtle.forward(100)
turtle.left(90) #箭头左转90度
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.penup()
turtle.goto(135,-5)
turtle.pendown()
turtle.forward(100)
turtle.left(90) #箭头左转90度
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.penup()
turtle.goto(5,-145)
turtle.pendown()
turtle.forward(100)
turtle.left(90) #箭头左转90度
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.penup()
turtle.goto(135,-145)
turtle.pendown()
turtle.forward(100)
turtle.left(90) #箭头左转90度
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
#绘制4个深红色矩形
turtle.width(2)
turtle.color("#be002f") #颜色查编程颜色代码,html的颜色代码通用
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
turtle.forward(100)
turtle.left(90) #箭头左转90度
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.penup()
turtle.goto(130,0)
turtle.pendown()
turtle.forward(100)
turtle.left(90) #箭头左转90度
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.penup()
turtle.goto(0,-140)
turtle.pendown()
turtle.forward(100)
turtle.left(90) #箭头左转90度
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.penup()
turtle.goto(130,-140)
turtle.pendown()
turtle.forward(100)
turtle.left(90) #箭头左转90度
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
原文链接:https://blog.csdn.net/MinskyYi/article/details/108868636
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。