python实现画五角星和螺旋线的示例

yipeiwu_com5年前Python基础

如下所示:

# -*- coding:UTF-8 -*-
__author__ = "zhangguodong"
__time__ = "2017.11.16"
 
import turtle
 
turtle.title("张国栋画五角星")
turtle.setup(500,300,0,0)
turtle.fillcolor("red")
turtle.begin_fill()
 
while True:
  turtle.forward(220)
  turtle.right(144)
  if abs(turtle.pos()) < 1:
      break
 
turtle.end_fill()
turtle.done()

python 画五角星和螺旋线

# -*- coding:UTF-8 -*-
__author__ = "zhangguodong"
__time__ = "2017.11.17"
 
import turtle
 
turtle.title("张国栋绘制螺旋线")
turtle.setup(400,400,0,0)
turtle.speed(10)  ###设置绘制时的速度
turtle.pensize(2)  ###设置画笔尺寸
 
for x in range(100):
  turtle.forward(2*x)
  turtle.left(90)
 
turtle.done()

python 画五角星和螺旋线

以上这篇python实现画五角星和螺旋线的示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

Python Flask基础教程示例代码

Python Flask基础教程示例代码

本文研究的主要是Python Flask基础教程,具体介绍如下。 安装:pip install flask即可 一个简单的Flask from flask import Flask...

python中实现定制类的特殊方法总结

看到类似__slots__这种形如__xxx__的变量或者函数名就要注意,这些在Python中是有特殊用途的。 __slots__我们已经知道怎么用了,__len__()方法我们也知道是...

python获取beautifulphoto随机某图片代码实例

Beautiful Photo!: http://www.beautifulphoto.net/ 复制代码 代码如下:import urllib2import re _random_ur...

python学生管理系统

python学生管理系统

这几天开始接触了python语言,这语言相对c语言简洁了不少,语言真是一通百通,学起来还是比较轻松,在熟悉了基本语法,列表(序列),元组以及字典之后写了一个最基础简单的的学生管理系统 能...

对python中的pop函数和append函数详解

对python中的pop函数和append函数详解

pop()函数 1、描述 pop() 函数用于移除列表中的一个元素(默认最后一个元素),并且返回该元素的值。 语法 pop()方法语法: list.pop(obj=list[-1])...