内容正文:
多彩几何学案
1、 认识Python
1、 打开Python的运行环境
2、 在界面中新建文件
3、 输入具体的代码
4、 保存文件
5、 运行代码文件
6、 显示运行结果
2、 导入turtle模块
import turtle
二、看一看、练一练
(
4
)
学科网(北京)股份有限公司
1、画一个边长为50的圆形
import turtle
turtle.circle(50)
turtle.done()
2、 画一个边长为50的红色正三角形
import turtle
turtle.color("red","red")
turtle.begin_fill()
turtle.circle(50,steps=3)
turtle.end_fill()
3、 画一个边长为50的黄色正四边形
import turtle
turtle.color("yellow","yellow")
turtle.begin_fill()
turtle.circle(50,steps=4)
turtle.end_fill()
4、 画一个边长为50的蓝色正五边形
import turtle
turtle.color("blue","blue")
turtle.begin_fill()
turtle.circle(50,steps=5)
turtle.end_fill()
5、 画一个半径为50的绿色圆形
import turtle
turtle.color("green","green")
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
3、 函数调用及解释语句
1、定位到坐标为(30,50)的位置
def flyTo():
turtle.penup()
turtle.goto(30, 50)
turtle.pendown()
#调用该函数
flyTo()
2、画半径为50的蓝色圆
def circle():
turtle.color(“blue”,“blue”)
turtle.begin_fill()
turtle.circle(50)
turtle.end_fill()
#调用该函数
circle()
3、画边长为100的粉色正三角形
def triangle():
turtle.color(“pink”,“pink”)
turtle.begin_fill()
turtle.circle(100, 3)
turtle.end_fill()
#调用该函数
triangle()
4、画长为30宽为90的紫色长方形
def rectangle():
turtle.color(“purple”,“purple”)
turtle.begin_fill()
turtle.fd(30)
turtle.left(90)
turtle.forward(90)
turtle.left(90)
turtle.forward(30)
turtle.left(90)
turtle.forward(90)
turtle.end_fill()
#调用该函数
rectangle()
附:
$$