Python选修课第二届Turtle绘图大赛

1)Partner:

学号:20181505025,郝春霖

学号:20181001113,杨禹凤

2)作品图示:

3)源代码:

  1 import turtle
  2 import random
  3 import time
  4
  5 turtle.setup(0.9,0.9,None,None)
  6 turtle.penup()
  7 turtle.fd(-318)
  8 turtle.pendown()
  9 turtle.pensize(3)#初始线条
 10 turtle.pencolor("brown")
 11 turtle.speed(0)#画笔速度
 12
 13 #整体背景颜色
 14 turtle.bgcolor("black")
 15
 16 #埃菲尔铁塔
 17 turtle.seth(0)
 18 turtle.fd(30)
 19 turtle.seth(100)
 20 turtle.fd(75)
 21 turtle.seth(98)
 22 turtle.fd(75)
 23 turtle.seth(95)
 24 turtle.fd(60)
 25 turtle.seth(70)
 26 turtle.fd(25)
 27 turtle.seth(180)
 28 turtle.fd(10)
 29 turtle.seth(90)
 30 turtle.fd(15)
 31 turtle.seth(0)
 32 turtle.fd(5)
 33 turtle.seth(90)
 34 turtle.circle(18,90)
 35 turtle.seth(90)
 36 turtle.fd(30)
 37 turtle.seth(-90)
 38 turtle.fd(15)
 39 turtle.seth(180)
 40 turtle.fd(5)
 41 turtle.seth(0)
 42 turtle.fd(10)
 43 turtle.seth(180)
 44 turtle.fd(5)
 45 turtle.seth(-90)
 46 turtle.fd(15)
 47 turtle.seth(180)
 48 turtle.circle(18,90)
 49 turtle.seth(0)
 50 turtle.fd(5)
 51 turtle.seth(-90)
 52 turtle.fd(15)
 53 turtle.seth(0)
 54 turtle.fd(28)
 55 turtle.seth(180)
 56 turtle.fd(28)
 57 turtle.seth(180)
 58 turtle.fd(10)
 59 turtle.seth(-70)
 60 turtle.fd(25)
 61 turtle.seth(-95)
 62 turtle.fd(60)
 63 turtle.seth(-98)
 64 turtle.fd(75)
 65 turtle.seth(-100)
 66 turtle.fd(75)
 67 turtle.seth(0)
 68 turtle.fd(86)
 69
 70 #铁塔上部分内部线条
 71 turtle.pensize(1)
 72 turtle.seth(155)
 73 turtle.fd(88)
 74 turtle.seth(20)
 75 turtle.fd(75)
 76 turtle.seth(160)
 77 turtle.fd(66)
 78 turtle.seth(20)
 79 turtle.fd(59)
 80 turtle.seth(160)
 81 turtle.fd(54)
 82 turtle.seth(20)
 83 turtle.fd(49)
 84 turtle.seth(160)
 85 turtle.fd(43)
 86 turtle.seth(20)
 87 turtle.fd(39)
 88 turtle.seth(160)
 89 turtle.fd(37)
 90 turtle.seth(20)
 91 turtle.fd(34)
 92 turtle.seth(160)
 93 turtle.fd(32)
 94 turtle.seth(11)
 95 turtle.fd(28)
 96 turtle.seth(180)
 97 turtle.fd(27)
 98 turtle.seth(90)
 99 turtle.fd(10)
100 turtle.seth(0)
101 turtle.fd(27)
102 turtle.seth(-90)
103 turtle.fd(10)
104 turtle.seth(180)
105 turtle.fd(27)
106 turtle.seth(-11)
107 turtle.fd(28)
108 turtle.seth(-160)
109 turtle.fd(32)
110 turtle.seth(-20)
111 turtle.fd(34)
112 turtle.seth(-160)
113 turtle.fd(37)
114 turtle.seth(-20)
115 turtle.fd(39)
116 turtle.seth(-160)
117 turtle.fd(43)
118 turtle.seth(-20)
119 turtle.fd(49)
120 turtle.seth(-160)
121 turtle.fd(54)
122 turtle.seth(-20)
123 turtle.fd(59)
124 turtle.seth(-160)
125 turtle.fd(66)
126 turtle.seth(-20)
127 turtle.fd(75)
128 turtle.seth(-155)
129 turtle.fd(88)
130 turtle.seth(0)
131 turtle.fd(43.4)
132 turtle.seth(90)
133 turtle.fd(225)
134 turtle.seth(-90)
135 turtle.fd(225)
136 turtle.seth(180)
137 turtle.fd(43.2)
138
139 #铁塔中部线条
140 turtle.pensize(3)
141 turtle.seth(-115)
142 turtle.fd(40)
143 turtle.seth(65)
144 turtle.fd(40)
145 turtle.seth(0)
146 turtle.fd(87)
147 turtle.seth(-65)
148 turtle.fd(40)
149 turtle.seth(180)
150 turtle.fd(10)
151 turtle.seth(90)
152 turtle.circle(8,180)
153 turtle.seth(180)
154 turtle.fd(5)
155 turtle.seth(90)
156 turtle.circle(8,180)
157 turtle.seth(180)
158 turtle.fd(5)
159 turtle.seth(90)
160 turtle.circle(8,180)
161 turtle.seth(180)
162 turtle.fd(5)
163 turtle.seth(90)
164 turtle.circle(8,180)
165 turtle.seth(180)
166 turtle.fd(5)
167 turtle.seth(90)
168 turtle.circle(8,180)
169 turtle.seth(180)
170 turtle.fd(10)
171 turtle.seth(0)
172 turtle.fd(130)
173 turtle.seth(-145)
174 turtle.fd(25)
175 turtle.seth(180)
176 turtle.fd(100)
177 turtle.seth(145)
178 turtle.fd(25)
179 turtle.seth(0)
180 turtle.fd(10)
181 turtle.seth(180)
182 turtle.fd(10)
183 turtle.seth(-40)
184 turtle.fd(25)
185 turtle.seth(-110)
186 turtle.fd(60)
187 turtle.seth(0)
188 turtle.fd(30)
189 turtle.seth(70)
190 turtle.fd(50)
191 turtle.seth(180)
192 turtle.fd(30)
193
194 #铁塔左中部内部线条
195 turtle.pensize(1)
196 turtle.seth(-30)
197 turtle.fd(30)
198 turtle.seth(-160)
199 turtle.fd(40)
200 turtle.seth(-35)
201 turtle.fd(31)
202 turtle.seth(106)
203 turtle.fd(49)
204 turtle.seth(70)
205 turtle.fd(10)
206 turtle.seth(0)
207 turtle.fd(100)
208
209 #铁塔中部线条
210 turtle.pensize(3)
211 turtle.seth(-70)
212 turtle.fd(60)
213 turtle.seth(180)
214 turtle.fd(30)
215 turtle.seth(110)
216 turtle.fd(50)
217 turtle.seth(0)
218 turtle.fd(30)
219
220 #铁塔右中部内部线条
221 turtle.pensize(1)
222 turtle.seth(-150)
223 turtle.fd(30)
224 turtle.seth(-20)
225 turtle.fd(40)
226 turtle.seth(-145)
227 turtle.fd(31)
228 turtle.seth(74)
229 turtle.fd(49)
230 turtle.seth(180)
231 turtle.fd(30)
232
233 #铁塔下部线条
234 turtle.pensize(3)
235 turtle.seth(90)
236 turtle.fd(8)
237 turtle.seth(180)
238 turtle.fd(45)
239 turtle.seth(-90)
240 turtle.fd(8)
241 turtle.seth(-90)
242 turtle.fd(50)
243 turtle.seth(180)
244 turtle.fd(60)
245 turtle.seth(-90)
246 turtle.fd(20)
247 turtle.seth(0)
248 turtle.fd(165)
249 turtle.seth(90)
250 turtle.fd(20)
251 turtle.seth(180)
252 turtle.fd(60)
253 turtle.seth(90)
254 turtle.fd(50)
255 turtle.seth(-90)
256 turtle.fd(70)
257 turtle.seth(180)
258 turtle.fd(45)
259 turtle.seth(90)
260 turtle.fd(20)
261 turtle.seth(-90)
262 turtle.fd(20)
263 turtle.seth(-120)
264 turtle.fd(120)
265 turtle.pensize(6)
266 turtle.seth(180)
267 turtle.fd(50)
268 turtle.pensize(3)
269 turtle.seth(60)
270 turtle.fd(120)
271 turtle.seth(0)
272 turtle.fd(95)
273 turtle.seth(-60)
274 turtle.fd(120)
275 turtle.pensize(6)
276 turtle.seth(0)
277 turtle.fd(50)
278 turtle.pensize(3)
279 turtle.seth(120)
280 turtle.fd(120)
281 turtle.pensize(1)
282 turtle.seth(-150)
283 turtle.fd(41)
284 turtle.seth(-20)
285 turtle.fd(60)
286 turtle.seth(-150)
287 turtle.fd(42)
288 turtle.seth(-40)
289 turtle.fd(62)
290 turtle.seth(97)
291 turtle.fd(62)
292 turtle.seth(120)
293 turtle.fd(48)
294 turtle.seth(180)
295 turtle.fd(145)
296 turtle.seth(-30)
297 turtle.fd(41)
298 turtle.seth(-161)
299 turtle.fd(60)
300 turtle.seth(-30)
301 turtle.fd(42)
302 turtle.seth(-140)
303 turtle.fd(65)
304 turtle.seth(81)
305 turtle.fd(62)
306 turtle.seth(60)
307 turtle.fd(47)
308 turtle.seth(0)
309 turtle.fd(50)
310 turtle.seth(-120)
311 turtle.fd(60)
312 turtle.pensize(3)
313 turtle.seth(0)
314 turtle.fd(25)
315 turtle.seth(90)
316 turtle.circle(-30,180)
317 turtle.seth(0)
318 turtle.fd(22)
319 turtle.penup()
320 turtle.fd(200)
321 turtle.pendown()
322
323
324
325 #月亮
326 turtle.penup()
327 turtle.goto(600,370)
328 turtle.pendown()
329 turtle.begin_fill()
330 turtle.color("yellow")
331 turtle.circle(-40,-360)
332 turtle.end_fill()
333
334 #星星
335 for i in range(80):
336     turtle.pensize(1)
337     x=random.randint(-900,900)
338     y=random.randint(100,500)
339     turtle.penup()
340     turtle.pencolor("yellow")
341     turtle.goto(x,y)
342     turtle.pendown()
343     turtle.seth(45)
344     for j in range(3):
345         turtle.fd(1)
346         turtle.right(90)
347     turtle.fd(1)
348
349 #公路小道左侧
350 turtle.penup()
351 turtle.goto(-360,-183)
352 turtle.pendown()
353 turtle.pencolor("gray")
354 turtle.pensize(2)
355 turtle.seth(-70)
356 turtle.fd(300)
357
358 #公路小道右侧
359 turtle.penup()
360 turtle.goto(-302,-183)
361 turtle.pendown()
362 turtle.pencolor("gray")
363 turtle.pensize(2)
364 turtle.seth(-47)
365 turtle.fd(300)
366
367 #马路线
368 turtle.penup()
369 turtle.goto(-330,-183)
370 turtle.pendown()
371 turtle.pencolor("gray")
372 turtle.pensize(3)
373 turtle.seth(-55)
374 turtle.fd(50)
375 turtle.penup()
376 turtle.goto(-290,-240)
377 turtle.pendown()
378 turtle.pencolor("gray")
379 turtle.pensize(4)
380 turtle.seth(-55)
381 turtle.fd(60)
382 turtle.penup()
383 turtle.goto(-240,-315)
384 turtle.pendown()
385 turtle.pencolor("gray")
386 turtle.pensize(5)
387 turtle.seth(-55)
388 turtle.fd(90)
389
390 #城市背景
391 turtle.penup()
392 turtle.goto(-481,-236)
393 turtle.pendown()
394 turtle.pencolor("white")
395 turtle.pensize(2)
396
397 #高楼(左侧)
398 for i in range(10):
399     turtle.pensize(2)
400     z=random.randint(200,350)#
401     x=random.randint(20,50)
402     turtle.seth(90)
403     turtle.fd(z)
404     turtle.seth(180)
405     turtle.fd(x)
406     turtle.seth(-90)
407     turtle.fd(z)
408     turtle.seth(0)
409     turtle.fd(x)
410     turtle.backward(x)
411 #高楼(右侧)
412 turtle.penup()
413 turtle.goto(-180,-236)
414 turtle.pendown()
415 for i in range(30):
416     turtle.pensize(2)
417     z=random.randint(200,350)
418     x=random.randint(20,50)
419     turtle.seth(90)
420     turtle.fd(z)
421     turtle.seth(0)
422     turtle.fd(x)
423     turtle.seth(-90)
424     turtle.fd(z)
425     turtle.seth(180)
426     turtle.fd(x)
427     turtle.backward(x)
428
429 #街边树木(左侧)
430 for i in range(6):
431     turtle.penup()
432     turtle.goto(-730+50*i,-280)
433     turtle.pendown()
434     turtle.pencolor("brown")
435     turtle.pensize(2)
436     turtle.seth(90)
437     turtle.fd(60)
438     for j in range(22):
439         turtle.pencolor("green")
440         turtle.seth(35+j*5)
441         turtle.fd(50)
442         turtle.backward(50)
443
444 #街边树木(右侧)
445 for i in range(20):
446     turtle.penup()
447     turtle.goto(-180+50*i,-280)
448     turtle.pendown()
449     turtle.pencolor("brown")
450     turtle.pensize(2)
451     turtle.seth(90)
452     turtle.fd(60)
453     for j in range(22):
454         turtle.pencolor("green")
455         turtle.seth(35+j*5)
456         turtle.fd(50)
457         turtle.backward(50)
458
459 #情人
460 turtle.penup()
461 turtle.goto(220,-330)
462 turtle.pendown()
463 turtle.pensize(2)
464 turtle.begin_fill()
465 turtle.color("brown")
466 turtle.seth(0)
467 turtle.fd(80)
468 turtle.seth(-90)
469 turtle.fd(30)
470 turtle.seth(180)
471 turtle.fd(80)
472 turtle.seth(90)
473 turtle.fd(30)
474 turtle.end_fill()
475 turtle.pencolor("gray")
476 turtle.seth(0)
477 turtle.fd(25)
478 turtle.circle(10,360)
479 turtle.fd(30)
480 turtle.circle(10,360)
481 turtle.penup()
482 turtle.goto(280,-315)
483 turtle.pendown()
484 turtle.pensize(4)
485 turtle.seth(-90)
486 turtle.fd(20)
487 for i in range(6):
488     turtle.penup()
489     turtle.goto(220+16*i,-360)
490     turtle.pendown()
491     turtle.pensize(2)
492     turtle.seth(-90)
493     if i==0 and i==5:
494         turtle.fd(30)
495     else:
496         turtle.fd(15)
497
498 #I Love You字体
499 turtle.penup()
500 turtle.goto(-100,0)
501 turtle.pendown()
502 turtle.pencolor("red")
503 turtle.pensize(3)
504 turtle.hideturtle()#隐藏
505 turtle.write("♥",  font = ("Times", 300,"bold"))
506 #turtle.hideturtle()#隐藏
507 time.sleep(1)#暂留1秒
508 turtle.undo()
509 turtle.penup()
510 turtle.goto(-100,200)
511 turtle.pendown()
512 turtle.pencolor("pink")
513 turtle.write("I Love You",font = ("Times", 38,"bold"))
514 turtle.hideturtle()#隐藏

4)代码演示:

链接:http://v.youku.com/v_show/id_XNDE3Mzg1NzI3Ng==.html?spm=a2h3j.8428770.3416059.1

原文地址:https://www.cnblogs.com/haochunlin/p/10836024.html

时间: 2024-10-09 10:15:09

Python选修课第二届Turtle绘图大赛的相关文章

Python选修课第一届Turtle绘图大赛田康林赵冰珂组

点击此处查看视频 from turtle import* setup(600,600,200,200) #脸 penup() goto(-190,0) seth(-90) pendown() pencolor('goldenrod3') pensize(5) begin_fill() circle(190,360) fillcolor('lightgoldenrod1') end_fill() #画眉毛 penup() goto(-135,155) seth(30) pendown() penc

某篮球巨星(第二届Turtle绘图大赛)

(a) 合作伙伴 王俊杰 20171204080姚涵 20171204078 (b)代码执行结果和视频 理想结果: 实际结果: 运行视频: 点击我观看 (c) 程序源码 import turtle as t import os wight = 700 height = 800 t.setup(wight,height) t.speed(0) def move_pen(x,y): t.pu() t.goto(x-wight/2+50,y-height/2+50) t.pd()def draw_to

使用python中的matplotlib进行绘图分析数据

http://blog.csdn.net/pipisorry/article/details/37742423 matplotlib 是python最著名的绘图库,它提供了一整套和matlab相似的命令API,十分适合交互式地进行制图.而且也可以方便地将它作为绘图控件,嵌入GUI应用程序中. 它的文档相当完备,并且 Gallery页面 中有上百幅缩略图,打开之后都有源程序.因此如果你需要绘制某种类型的图,只需要在这个页面中浏览/复制/粘贴一下,基本上都能搞定. 在Linux下比较著名的数据图工具

Python turtle绘图实例分析

画一个红色的五角星 from turtle import * color('red','red') begin_fill() for i in range(5): fd(200) rt(144) end_fill() done() 效果图: 画一条蟒蛇 #PythonDraw.py import turtle #turtle.setup(650,350,200,200) turtle.penup() turtle.fd(-250) turtle.pendown() turtle.pensize(

python绘制图形(Turtle模块)

用python的Turtle模块可以绘制很多精美的图形,下面简单介绍一下使用方法. 需要用到的工具有python,python 的安装这里就不再细说.自行搜索. 1 from turtle import * #引入turtle模块 2 color('red', 'yellow') #设置绘制的颜色和填充颜色 3 4 # 海龟设置 5 hideturtle() # 隐藏箭头 6 speed(10) # 设置速度 7 # 前进后退,左转右转 8 fd(100) # 前进100像素(forward(1

河北大学python选修课00次作业

学习python认为挺好玩的一件事.看到很多关于python的东西在网上,看到有这个课,认为只是选修课,别人也可以选,自己想不能被别人落下,别人都会,我不会可不行. 而且认为python是一个很强大的工具,既然有这么强大的工具,会对以后的生活有一定的帮助,自己会学好的,以后的生活是自己想要的,感觉会编程是很正常必须的,虽然我以前也会编程,但不会错过任何一个成长的机会,我想说我想说说的话,做自己想做的事. 以后会有用的,万一以后想做了,我还有基础,以后的路谁都不知到底会怎样,可能比较迷茫,但我会走

python之绘制图形库turtle

关于绘制图形库turtle# 画布上,默认有一个坐标原点为画布中心的坐标轴(0,0),默认"standard"模式坐标原点上有一只面朝x轴正方向小乌龟 一:海龟箭头Turtle相关方法##############################       1.绘制的运动        ##############################a).移动和绘制# turtle.forward(distance) | turtle.fd(distance)# 画笔向绘制方向的当前方向移

python标准库《turtle》

FUNCTIONS Screen() Return the singleton screen object. If none exists at the moment, create a new one and return it, else return the existing one. addshape(name, shape=None) Adds a turtle shape to TurtleScreen's shapelist. Arguments: (1) name is the

python中,使用matplotlib绘图时,图片上文字无法显示问题。

在使用python过程中,我们往往需要使用matplotlib进行图片的绘制,在绘图过程中,我们有时需要在图片上进行文字的显示,在使用过程中,会出现文字无法显示的问题.如下图: 遇到上述问题我们只需在代码中加入如下语句即可解决: from pylab import mpl mpl.rcParams['font.sans-serif'] = ['SimHei']如下图: 原文地址:https://www.cnblogs.com/Leo-Xia/p/9997408.html