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

第二周练习

时间:2020-03-28 16:22:18      阅读:84      评论:0      收藏:0      [点我收藏+]

标签:lse   col   height   src   太极   div   color   down   国际   

1、画五角星

技术图片

 

 

 

技术图片
import turtle

turtle.pensize(5)
turtle.pencolor("yellow")
turtle.fillcolor("red")

turtle.begin_fill()
for i in range(5):
    turtle.forward(200)
    turtle.right(-72)
    turtle.forward(200)
    turtle.left(-144)
turtle.end_fill()

turtle.hideturtle() 
turtle.done()         
技术图片

 

运行结果:

技术图片

 

 

 

 

2、

技术图片技术图片

 

 

 

技术图片
import turtle
radius=int(input())
number=int(input())
color=input()
turtle.pensize(2)
turtle.pencolor(color)
for i in range(number):
    turtle.circle(radius+i*10)
    turtle.penup()
    turtle.right(90)
    turtle.forward(10)
    turtle.left(90)
    turtle.pendown()

turtle.hideturtle()   
turtle.done()         
技术图片

 

输入:

20

4

red

 

运行结果:

技术图片

 

 

3、渐变的圆

技术图片

 

 

 

技术图片
import turtle
n=int(input())
turtle.pensize(3)
turtle.pencolor("blue")
turtle.fillcolor("yellow")
turtle.begin_fill()
if n in [3,4,5,6,7,8,9]:
    for i in range(7):
        turtle.circle(50,steps=n+i)
        turtle.forward(100)

    turtle.circle(50)
else:
    turtle.clear()
turtle.end_fill()
turtle.hideturtle()
turtle.done()         
技术图片

 

 

输入:

3

 

运行结果:

技术图片

 

 

4、

 

技术图片技术图片

 

技术图片
import turtle
turtle.forward(100)
for i in range(2):
    turtle.right(120)
    turtle.forward(100)

turtle.right(60)
turtle.forward(100)
turtle.right(120)
for i in range(3):
    turtle.forward(200)
    turtle.right(120) 
turtle.hideturtle()
turtle.done()    
技术图片

 

运行结果:

 技术图片

 

 

 

 

5、

技术图片技术图片

 

 

技术图片
import turtle
coordA=(-110,0,110,-55,55)     
coordB=(-25,-25,-25,-75,-75)
colors=["red","blue","green","yellow","black"]
turtle.pensize(5)
for i in range(5):
    turtle.color(colors[i])
    turtle.penup()
    turtle.goto(coordA[i],coordB[i])
    turtle.pendown()
    turtle.circle(45)
turtle.hideturtle()
turtle.done()  
技术图片

 

 

 

 

运行结果:

技术图片

 

6、

 技术图片

 

 技术图片

 

技术图片
import turtle
turtle.circle(100)
turtle.fillcolor(‘black‘)
turtle.begin_fill()
turtle.circle(50,-180)
turtle.end_fill()
turtle.circle(-50,-180)
turtle.begin_fill()
turtle.circle(-100,180)
turtle.end_fill()
turtle.circle(-100,180)
turtle.fillcolor(‘white‘)
turtle.begin_fill()
turtle.circle(-50,180)
turtle.end_fill()

turtle.penup()
turtle.right(90)
turtle.forward(40)
turtle.right(90)
turtle.fillcolor(‘black‘)
turtle.begin_fill()
turtle.circle(12)
turtle.end_fill()

turtle.penup()
turtle.right(90)
turtle.forward(80)
turtle.right(90)
turtle.fillcolor(‘white‘)
turtle.begin_fill()
turtle.circle(12)
turtle.end_fill()

turtle.hideturtle()
turtle.done()  
技术图片

 

运行结果:

技术图片

 

 

 

7、画国际象棋盘

技术图片技术图片

 

 

 

技术图片
import turtle
s=int(input())
turtle.penup()
turtle.goto(-150,150)
turtle.pendown()
for i in range(4):
    for i in range(4):
        turtle.forward(s)
        turtle.fillcolor(‘black‘)
        turtle.begin_fill()
        turtle.right(90)
        turtle.forward(s)
        turtle.left(90)
        turtle.forward(s)
        turtle.left(90)
        turtle.forward(s)
        turtle.right(90)
        turtle.end_fill()
    turtle.right(90)
    turtle.forward(s)
    turtle.right(90)
    for i in range(4):
        turtle.forward(s)
        turtle.fillcolor(‘black‘)
        turtle.begin_fill()
        turtle.left(90)
        turtle.forward(s)
        turtle.right(90)
        turtle.forward(s)
        turtle.right(90)
        turtle.forward(s)
        turtle.left(90)
        turtle.end_fill()
    turtle.left(90)
    turtle.forward(s)
    turtle.left(90)
turtle.right(-180)
for i in range(4):
    turtle.right(90)
    turtle.fd(8*s)
turtle.hideturtle()
turtle.done()  
技术图片

输入:

50

 

运行结果:

技术图片

第二周练习

标签:lse   col   height   src   太极   div   color   down   国际   

原文地址:https://www.cnblogs.com/567823a/p/12587737.html

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