码迷,mamicode.com
首页 > 其他好文 > 详细

第一次作业

时间:2018-04-06 13:57:06      阅读:210      评论:0      收藏:0      [点我收藏+]

标签:import   tle   family   orange   blog   body   class   set   nec   

1.三角形

import turtle
turtle.pendown()
turtle.fd(100)
turtle.seth(-120)
turtle.fd(100)
turtle.seth(120)
turtle.fd(100)
turtle.seth(60)
turtle.fd(100)
turtle.seth(-60)
turtle.fd(200)
turtle.seth(-180)
turtle.fd(200)
turtle.seth(60)
turtle.fd(100)
turtle.seth(0)

 

2.没有角的正方形

import turtle
turtle.penup()
turtle.fd(30)
turtle.pendown()
turtle.fd(60)
turtle.penup()
turtle.fd(30)
turtle.seth(90)
turtle.fd(30)
turtle.pendown()
turtle.fd(60)
turtle.penup()
turtle.fd(30)
turtle.seth(-180)
turtle.fd(30)
turtle.pendown()
turtle.fd(60)
turtle.penup()
turtle.fd(30)
turtle.seth(-90)
turtle.fd(30)
turtle.pendown()
turtle.fd(60)

 

3.六角形

import turtle
turtle.seth(90)
turtle.pendown()
turtle.fd(180)
turtle.seth(-30)
turtle.fd(180)
turtle.seth(-150)
turtle.fd(180)
turtle.seth(90)
turtle.fd(120)
turtle.seth(30)
turtle.fd(120)
turtle.seth(-90)
turtle.fd(180)
turtle.seth(150)
turtle.fd(180)
turtle.seth(30)
turtle.fd(60)

 

4.正方形螺旋线

a=6
import turtle
turtle.pendown()
turtle.seth(90)
turtle.fd(3)
turtle.seth(-180)
turtle.fd(3)
turtle.seth(-90)
turtle.fd(6)
turtle.seth(0)
for i in range(24):
   turtle.fd(a)
   turtle.seth(90)
   a=a+3
   turtle.fd(a)
   turtle.seth(-180)
   a=a+3
   turtle.fd(a)
   turtle.seth(-90)
   a=a+3
   turtle.fd(a)
   turtle.seth(0)
   a=a+3

 

5.蟒蛇

import turtle
 
def drawSnake(rad,angle,len,neckrad):
 
  colors = ["red","orange","yellow","green","cyan","blue"]
  for i in range(len):
    turtle.color(colors[i])
    turtle.circle(rad,angle)
    turtle.circle(-rad,angle)
 
  turtle.color("purple")
  turtle.circle(rad,angle/2)
  turtle.fd(rad)
  turtle.circle(neckrad+1,180)
  turtle.fd(rad*2/3)
 
def main():
  turtle.setup(1300,800,0,0)
  turtle.penup()
  turtle.goto(-350,0)
  turtle.pendown()
  pythonsize = 30
  turtle.pensize(pythonsize)
  turtle.seth(-40)
  drawSnake(40,80,6,pythonsize/2)
 
main()

 

第一次作业

标签:import   tle   family   orange   blog   body   class   set   nec   

原文地址:https://www.cnblogs.com/w848854436/p/8727233.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!