第二周作业

一、画五角星

import turtle

turtle.pensize(6)
turtle.pencolor("yellow")
turtle.fillcolor("red")
turtle.begin_fill()
for i in range(5):
    turtle.fd(60)
    turtle.left(72)
    turtle.fd(60)
    turtle.right(144)
turtle.end_fill()

  第二周作业_第1张图片

二、画一组同心圆

import turtle

rad = eval(input("输入一个正整数: "))
a = eval(input("圆的个数: "))
color = (input("画笔颜色: "))

for i in range(a):
    turtle.pencolor(color)
    turtle.circle(rad,360)
    turtle.seth(-90)
    turtle.penup()
    turtle.fd(20)
    turtle.pendown()
    turtle.seth(0)
    rad = rad + 20

  第二周作业_第2张图片

三、渐变的圆

import turtle

number = int(input())
turtle.penup()
turtle.fd(-300)
turtle.seth(0)
turtle.pendown()
turtle.pensize(3)
turtle.pencolor('blue')
turtle.fillcolor('yellow')
turtle.begin_fill()

for i in range(3,number):
    turtle.circle(50, steps=i)
    turtle.forward(100)
turtle.circle(50, steps=number)

turtle.end_fill()
turtle.done()

  第二周作业_第3张图片

四、画叠加的等边三角形

import turtle

for i in range(3):
    turtle.fd(200)
    turtle.left(120)
turtle.penup()
turtle.fd(100)
turtle.seth(60)
turtle.pendown()
for i in range(3):
    turtle.fd(100)
    turtle.left(120)

  第二周作业_第4张图片

五、画奥运五环

import turtle

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

  第二周作业_第5张图片

六、画太极图

import turtle
c = ("white","black")
turtle.fillcolor(c[1])
turtle.begin_fill()
turtle.circle(100,180)
turtle.seth(-180)
turtle.circle(50,-180)
turtle.seth(-180)
turtle.circle(50,180)
turtle.seth(90)
turtle.penup()
turtle.fd(135)
turtle.seth(0)
turtle.pendown()
turtle.circle(15)
turtle.end_fill()

turtle.seth(90)
turtle.penup()
turtle.fd(65)
turtle.seth(180)
turtle.pendown()
turtle.circle(100,180)
turtle.fillcolor(c[0])
turtle.begin_fill()
turtle.seth(90)
turtle.penup()
turtle.fd(35)
turtle.seth(0)
turtle.pendown()
turtle.circle(15)
turtle.end_fill()

  第二周作业_第6张图片

七、画国际象棋盘

import turtle
i = eval(input())
for num in range(-4*i, 5*i, i):
    turtle.up()
    turtle.goto(-4*i, num)
    turtle.down()
    turtle.forward(i*8)
turtle.right(90)
for num1 in range(-4*i, 5*i, i):
    turtle.up()
    turtle.goto(num1,4*i)
    turtle.down()
    turtle.forward(i*8)
    
for x in range(-3*i,4*i,2*i):
    for y in range(-4*i,4*i,2*i):
        turtle.up()
        turtle.goto(x, y)
        turtle.down()
        turtle.begin_fill()
        turtle.fillcolor('black')
        for b in range(4):
            turtle.right(90)
            turtle.forward(i)
        turtle.end_fill()
turtle.up()
turtle.goto(4*i, 4*i)
turtle.down()
for x1 in range(-2*i,5*i,2*i):
    for y1 in range(-3*i,5*i,2*i):
        turtle.up()
        turtle.goto(x1, y1)
        turtle.down()
        turtle.begin_fill()
        turtle.fillcolor('black')
        for b in range(4):
            turtle.right(90)
            turtle.forward(i)
        turtle.end_fill()

  第二周作业_第7张图片

 

你可能感兴趣的:(第二周作业)