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

yipeiwu_com6年前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 内置函数complex详解

英文文档: class complex([real[, imag]]) Return a complex number with the value real + imag*1j or...

python实现根据主机名字获得所有ip地址的方法

本文实例讲述了python实现根据主机名字获得所有ip地址的方法。分享给大家供大家参考。具体实现方法如下: # -*- coding: utf-8 -*- import sys, s...

Pytorch 实现冻结指定卷积层的参数

python代码 for i, para in enumerate(self._net.module.features.parameters()): if i &...

python中二维阵列的变换实例

本文实例讲述了python中二维阵列的变换方法。分享给大家供大家参考。具体方法如下: 先看如下代码: arr = [ [1, 2, 3], [4, 5, 6], [7, 8,9],...

Python3随机漫步生成数据并绘制

Python3随机漫步生成数据并绘制

本文为大家分享了Python3随机漫步生成数据并绘制的具体代码,供大家参考,具体内容如下 random_walk.py from random import choice #生成随...