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

第二周练习

时间:2020-03-14 22:18:33      阅读:77      评论:0      收藏:0      [点我收藏+]

标签:gif   坐标   国际象棋   eve   国际   tle   event   black   lse   

1.五角星

技术图片
import turtle

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

turtle.begin_fill()

for _ in range(5):
    turtle.fd(120)
    turtle.right(144)
    turtle.fd(120)
    turtle.left(72)
turtle.end_fill()
View Code

技术图片

 

2.同心圆

技术图片
import turtle

r = eval(input())
m = eval(input())
y = input()
i = 0

turtle.pensize(5)
turtle.pencolor(y)

turtle.begin_fill()
for _ in range(m):
    turtle.circle(r)
    r = r+20
    i = i+20
    turtle.penup()
    turtle.goto(0,-i)
    turtle.pendown()
View Code

技术图片

 

3.渐变圆

技术图片
import turtle

n = eval(input())
m = 2

turtle.pensize(3)
turtle.pencolor("blue")
turtle.fillcolor("yellow")
turtle.penup()
turtle.forward(-350)
turtle.pendown()

turtle.begin_fill()
for _ in range(n-2):
    m = m+1
    turtle.circle(25,steps=m)
    turtle.forward(70)
    
turtle.circle(25)

turtle.end_fill()
View Code

技术图片

 

4.五环

技术图片
import turtle

turtle.pensize(5)
color=("red","blue","green","yellow","black")
i=0

coordA=(-110,0,110,-55,55)     #五个图起点坐标的x值
coordB=(-25,-25,-25,-75,-75)   #五个圆起点坐标的y值

turtle.begin_fill()
for _ in range(5):
    turtle.penup()
    turtle.goto(coordA[i],coordB[i])
    turtle.color(color[i])
    i = i+1
    turtle.pendown()
    turtle.circle(45)
View Code

技术图片

 

5.太极

技术图片
import turtle

turtle.pensize(3)
turtle.pencolor("black")


turtle.begin_fill()
turtle.penup()
turtle.goto(0,-300)
turtle.pendown()
turtle.circle(230,180)
turtle.fillcolor("black")
turtle.end_fill()
turtle.begin_fill()
turtle.penup()
turtle.goto(0,160)
turtle.pendown()
turtle.circle(230,180)
turtle.fillcolor("white")
turtle.end_fill()
turtle.begin_fill()
turtle.circle(115,-180)
turtle.fillcolor("black")
turtle.end_fill()
turtle.begin_fill()
turtle.circle(-115,-180)
turtle.fillcolor("white")
turtle.end_fill()
turtle.begin_fill()
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
turtle.circle(30)
turtle.fillcolor("black")
turtle.end_fill()
turtle.begin_fill()
turtle.penup()
turtle.goto(0,-200)
turtle.pendown()
turtle.circle(30)
turtle.fillcolor("white")
turtle.end_fill()
View Code

技术图片

 

6.国际象棋盘

技术图片
import turtle

t = 0
n = eval(input())
turtle.pensize(3)
turtle.pencolor("black")


for _ in range(8):   
    if t % 2 == 0:
        turtle.penup()
        i = 1
        turtle.goto(n*t,-n)
        turtle.pendown()
        turtle.begin_fill()
        for _ in range(4):
            for _ in range(4):
                turtle.forward(n)
                turtle.right(90)
                turtle.fillcolor("black")
            turtle.penup()
            i = i+2
            turtle.goto(n*t,-n*i)
            turtle.pendown()
        turtle.end_fill()
        t = t+1
    else:
        turtle.penup()
        i = 0
        turtle.goto(n*t,0)
        turtle.pendown()
        for _ in range(4):
            turtle.begin_fill()
            for _ in range(4):
                turtle.forward(n)
                turtle.fillcolor("black")
                turtle.right(90)
            turtle.penup()
            i = i+1
            turtle.goto(n*t,-n*2*i)
            turtle.pendown()
            turtle.end_fill()
        turtle.penup()
        turtle.goto(n*t,0)
        turtle.pendown()
        t = t+1
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
for _ in range(4):
    turtle.forward(n*8)
    turtle.right(90)
View Code

技术图片

第二周练习

标签:gif   坐标   国际象棋   eve   国际   tle   event   black   lse   

原文地址:https://www.cnblogs.com/ikome/p/12494364.html

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