Python学习笔记四(turtle模块画图练习)
Turtle画图:
import turtle as t
import time
t.speed(5)
t.setup(900,900)
t.penup()
t.goto(0,-200)
t.pendown()
t.circle(200)
t.penup()
t.goto(-200,0)
t.pendown()
t.circle(200,90)
t.penup()
t.goto(-200,0)
t.setheading(0)
t.pendown()
t.circle(-200,90)
t.penup()
t.goto(200,0)
t.setheading(180)
t.pendown()
t.circle(200,90)
t.penup()
t.goto(200,0)
t.setheading(180)
t.pendown()
t.circle(-200,90)
t.penup()
Turtle画图:四瓣花,每一瓣由半径为100像素半圆弧的组成,如下图:
import turtle as t
import time
t.speed(5)
t.setup(900,900)
t.penup()
t.goto(-100,-100)
t.setheading(270)
t.pendown()
t.circle(100,180)
t.penup()
t.goto(100,-100)
t.setheading(0)
t.pendown()
t.circle(100,180)
t.penup()
t.goto(100,100)
t.setheading(90)
t.pendown()
t.circle(100,180)
t.penup()
t.goto(-100,100)
t.setheading(180)
t.pendown()
t.circle(100,180)
t.penup()
time.sleep(3)
Turtle绘制如下图形:
import turtle as t
import time
t.speed(5)
t.setup(800,800)
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()
time.sleep(3)
Turtle绘制图形:
import turtle as t
import time
t.speed(5)
t.pensize(3)
t.setup(800,800)
t.pendown()
t.color("red","Black")
t.begin_fill()
t.left(30)
t.forward(100)
t.right(120)
t.forward(100)
t.right(120)
t.forward(200)
t.left(120)
t.forward(100)
t.left(120)
t.forward(100)
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()
time.sleep(3)
Turtle绘制斯诺特图形,如下:
import turtle as t
import time
t.speed(5)
t.setup(800,800)
t.penup()
def Srt(r,n):
for a in range(0,n):
t.goto(0, -200)
# t.dot(5,"red")
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(r+r)
Srt(50,4)
time.sleep(3)
- Python 【模块】 学习笔记
- python学习笔记7.1-内建模块os
- Python学习笔记四(Python OS模块)
- Python学习笔记--模块
- Python学习笔记(四十一)— 内置模块(10)urllib
- python基础教程_学习笔记12:充电时刻——模块
- Python SciPy Sparse模块学习笔记
- Python计算机视觉编程练习9:argparse 模块学习
- Python学习笔记4(函数与模块)
- Python学习笔记:函数、模块和包
- python学习笔记 常用第三方模块
- Python之学习笔记(模块的使用)
- Python模块学习笔记— —hashlib
- python 学习笔记10-----模块
- Python的学习笔记DAY8---爬虫练习之煎蛋网妹子图爬虫
- Python学习笔记 - day9 - 模块与包
- csv模块学习:Python学习笔记—CSV模块读写数据
- Python学习笔记6-Python中re(正则表达式)模块学习
- Python3学习笔记05-字典、文件输入输出、模块、函数参数传递
- Python学习笔记-4(模块:collections、itertools、xml)