Python学习笔记四(turtle模块画图练习)

Turtle画图:

import turtle as t

t.speed(5)
t.penup()

t.goto(0,200)
t.pendown()
t.circle(-200)
t.penup()

for i in range(4):
    t.setheading((3-i)*90)
    t.pendown()
    t.circle(200, 90)
    t.penup()

 Turtle画图:如图

import turtle as t

t.speed(5)
t.penup()

t.goto(-100,100)
for i in range(4):
    t.setheading((3-i)*90)
    t.pendown()
    t.circle(100,180)
    t.penup()

 

Turtle画图:四瓣花,每一瓣由半径为100像素半圆弧的组成,如下图:

import turtle as t

t.speed(5)
t.penup()

t.goto(-100,-100)
t.setheading(270)
for i in range(4):
    t.pendown()
    t.circle(100,180)
    t.penup()
    t.setheading(i*90)

 

 

Turtle绘制如下图形:

import turtle as t

t.speed(5)
t.penup()

for a in range(3):
    t.home()
    t.setheading(120 * a)
    t.pendown()
    t.color("black", "black")
    t.begin_fill()
    t.forward(100)
    t.left(60)
    t.forward(100)
    t.left(120)
    t.forward(100)
    t.left(60)
    t.forward(100)
    t.end_fill()
    t.penup()

 

Turtle绘制图形:

import turtle as t

t.speed(5)
t.pensize(3)

t.pendown()
for i in [90,270]:
    t.setheading(i)
    t.color("red", "Black")
    t.begin_fill()
    t.circle(100, steps=3)
    t.end_fill()
t.penup()

t.home()
t.goto(0,-15)
t.pendown()
t.color("red","Black")
t.begin_fill()
t.circle(15)
t.end_fill()
t.penup()

 

Turtle绘制斯诺特图形,如下:

import turtle as t

t.speed(5)
t.penup()


def Srt(r, n):
    for a in range(0, n):
        t.goto(0, -100)
        t.setheading(120)
        t.forward(2 * r * a)
        t.setheading(0)
        for b in range(0, a + 1):
            t.pendown()
            t.circle(r)
            t.penup()
            t.forward(2*r)

Srt(20,5)

制斯诺特图形思路图:(我绘图的思路图,也不知道除了我,会不会有人看懂.....自己理得都有点费劲,应该不是最简的方法,但想不出其他的了......)

 

 

  • 9
    点赞
  • 72
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值