Python简单应用题.docx
《Python简单应用题.docx》由会员分享,可在线阅读,更多相关《Python简单应用题.docx(15页珍藏版)》请在冰豆网上搜索。
Python简单应用题
1.使用turtle库绘制轮廓颜色为红色(red)、填充颜色为粉红色(pink)的心形图形,效果如下图所示。
阅读程序框架,补充横线处代码。
fromturtleimport*
color('red',____①____)
(____②____)
left(135)
fd(100)
right(180)
circle(50,–180)
left(90)
circle(50,–180)
right(180)
fd(100)
end_fill()
hideturtle()
done()
输出
参考代码:
fromturtleimport*
color('red','pink')
begin_fill()
left(135)
fd(100)
right(180)
circle(50,-180)
left(90)
circle(50,-180)
right(180)
fd(100)
end_fill()
hideturtle()
done()
2.使用turtle库绘制红色五角星图形,效果如下图所示。
阅读程序框架,补充横线处代码。
(____①____)
setup(400,400)
penup()
goto(–100,50)
pendown()
color("red")
begin_fill()
foriinrange(5):
forward(200)
(____②____)
end_fill()
hideturtle()
done()
输出
参考代码:
fromturtleimport*
setup(400,400)
penup()
goto(-100,50)
pendown()
color("red")
begin_fill()
foriinrange(5):
forward(200)
right(144)
end_fill()
hideturtle()
done()
3.使用turtle库绘制正方形螺旋线,效果如下图所示。
阅读程序框架,补充横线处代码。
importturtle
n=10
foriinrange(1,10,1):
forjin[90,180,–90,0]:
(____①____)
(____②____)
n+=5
输出
参考代码:
importturtle
n=10
foriinrange(1,10,1):
forjin[90,180,-90,0]:
(j)
(n)
n+=5
4.使用turtle库绘制简单城市剪影图形,效果如下图所示。
阅读程序框架,补充横线处代码。
importturtle
(800,300)
()
(–350)
()
defDrawLine(____①____)
foranglein[0,90,–90,–90,90]:
(angle)
(size)
foriin[20,30,40,50,40,30,20]:
(____②____)
()
()
输出
参考代码:
importturtle
(800,300)
()
(-350)
()
defDrawLine(size):
foranglein[0,90,-90,-90,90]:
(angle)
(size)
foriin[20,30,40,50,40,30,20]:
DrawLine(i)
()
()
5.使用turtle库绘制同心圆图形,效果如下图所示。
阅读程序框架,补充横线处代码。
(____①____)
defDrawCctCircle(n):
()
(0,–n)
()
(____②____)
foriinrange(20,100,20):
DrawCctCircle(i)
()
()
输出
参考代码:
importturtleast
defDrwaCctCircle(n):
()
(0,-n)
()
(n)
foriinrange(20,100,20):
DrwaCctCircle(i)
()
()
6.使用turtle库绘制5种多边形,效果如下图所示。
阅读程序框架,补充横线处代码。
fromturtleimport*
foriinrange(5):
(____①____)#画笔抬起
goto(-200+100*i,-50)
pendown()
(____②____)(40,steps=3+i)#画某个形状
done()
输出
参考代码:
fromturtleimport*
foriinrange(5):
penup()
goto(-200+100*i,-50)
pendown()
circle(40,steps=3+i)
done()
7.使用turtle库的()函数和()函数绘制一个边长为200的正方形,效果如下图所示。
请结合格式框架,补充横线处代码。