码迷,mamicode.com
首页 > 编程语言 > 详细

python 绘图编程练习

时间:2020-03-14 23:35:22      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:for   end   LLC   tle   imp   style   white   inf   隐藏   

------------恢复内容开始------------

黄边五角星

import turtle

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

turtle.begin_fill()
for i in range(6):
    turtle.forward(100)
    turtle.right(144)
    turtle.forward(100)
    turtle.left(72)
turtle.end_fill()

turtle.hideturtle()   #隐藏画笔
turtle.done()         #结束绘制

技术图片

 

 

同心圆

import turtle
s = eval(input())
j = eval(input())
turtle.pencolor(input())
for i in range(j + 1):
    turtle.penup()
    turtle.goto(0,-i*20)
    turtle.pendown()
    turtle.circle(s*i,360)
turtle.done()

技术图片

 

 

渐变的圆

import turtle
n = eval(input("请输入一个大于等于三且小于十的整数:"))
turtle.penup()
turtle.fd(-500)
turtle.fillcolor("yellow")
turtle.pencolor("blue")
turtle.pendown()
turtle.pensize(3)
turtle.begin_fill()
for i in range(n):
    turtle.circle(50,steps = i+3)
    turtle.fd(100)
turtle.circle(50,360)
turtle.end_fill()
turtle.hideturtle()

技术图片

 

叠加三角形

import turtle
turtle.penup()
turtle.fd(75)
turtle.right(60)
turtle.fd(150)
turtle.pendown()
for i in range(3):
    turtle.right(120)
    turtle.fd(300)
turtle.penup()
turtle.right(120)
turtle.fd(150)
turtle.right(60)
turtle.pendown()
for i in range(3):
    turtle.fd(150)
    turtle.right(120)
turtle.hideturtle()
turtle.done()

技术图片

 

奥运五环

import turtle
coorA = (-110,0,110,-55,55)
coorB = (-25,-25,-25,-75,-75)
my_colors = ("red","blue","green","yellow","black")
turtle.pensize(5)
for i in range(5):
    turtle.penup()
    turtle.goto(coorA[i],coorB[i])
    turtle.pendown()
    turtle.color(my_colors[i%len(my_colors)])
    turtle.circle(45,360)
turtle.hideturtle()
turtle.done()

技术图片

太极图

import turtle
turtle.fillcolor("black")
turtle.begin_fill()
turtle.circle(100, 180)
turtle.circle(50, -180)
turtle.circle(-50, -180)
turtle.end_fill()
turtle.penup()
turtle.right(90)
turtle.fd(40)
turtle.pendown()
turtle.right(90)
turtle.fillcolor("white")
turtle.begin_fill()
turtle.circle(10, 360)
turtle.end_fill()
turtle.right(90)
turtle.fd(40)
turtle.right(90)
turtle.circle(-100, 180)
turtle.right(90)
turtle.penup()
turtle.fd(40)
turtle.fillcolor("black")
turtle.begin_fill()
turtle.pendown()
turtle.circle(10,360)
turtle.end_fill()
turtle.hideturtle()
turtle.done()

技术图片

 

国际棋盘

import turtle as t
a = eval(input())
for i in range(8):
    for j in range(8):
        t.penup()
        t.goto(i*a, j*a)
        t.pendown()
        t.begin_fill()
        if(i+j)%2 ==0:
            t.color("white")
        else:
            t.color("black")
        for k in range(4):
            t.fd(a)
            t.right(90)
        t.end_fill()
t.pencolor("black")
t.fd(a)
for n in range(4):
    t.right(90)
    t.fd(a*8)
t.hideturtle()
t.done()

技术图片

python 绘图编程练习

标签:for   end   LLC   tle   imp   style   white   inf   隐藏   

原文地址:https://www.cnblogs.com/wangyingjie123/p/12495153.html

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