博客
关于我
[python] math与turtle库之蝴蝶曲线
阅读量:365 次
发布时间:2019-03-04

本文共 533 字,大约阅读时间需要 1 分钟。

【python代码】math与turtle库之蝴蝶曲线的运用

几个turtle库基本函数:

1:turtle.pensize(x) :X大小控制画笔大小
2:turtle.pencolor(“color”):画笔颜色控制,color为想要输入的颜色名称

引入turtle库跟math库:

from turtle import*
from math import*
几个math函数:
exp(x):表示为e的x次方
pow(x,y):表示为x的y次方

[python] math与turtle库之蝴蝶曲线代码:

**from turtle import * from math import * pensize(3) pencolor("red") #画笔颜色 def draw(a,end): t=0 while t<24*end: x=a*sin(t)*(exp(cos(t))-2*cos(4*t)+pow(sin(t/12),5)) y=a*cos(t)*(exp(cos(t))-2*cos(4*t)+pow(sin(t/12),5)) goto(x,y) t=t+0.05 if __name__ == '__main__': draw(60,pi)**
代码
效果图

转载地址:http://diyg.baihongyu.com/

你可能感兴趣的文章
mysql中having的用法
查看>>
MySQL中interactive_timeout和wait_timeout的区别
查看>>
mysql中int、bigint、smallint 和 tinyint的区别、char和varchar的区别详细介绍
查看>>
mysql中json_extract的使用方法
查看>>
mysql中json_extract的使用方法
查看>>
mysql中null和空字符串的区别与问题!
查看>>
MySQL中ON DUPLICATE KEY UPDATE的介绍与使用、批量更新、存在即更新不存在则插入
查看>>
MYSQL中TINYINT的取值范围
查看>>
Mysql中varchar类型数字排序不对踩坑记录
查看>>
mysql中出现update-alternatives: 错误: 候选项路径 /etc/mysql/mysql.cnf 不存在 dpkg: 处理软件包 mysql-server-8.0的解决方法(全)
查看>>
MySQL中地理位置数据扩展geometry的使用心得
查看>>
Mysql中存储引擎简介、修改、查询、选择
查看>>
mysql中实现rownum,对结果进行排序
查看>>
mysql中对于数据库的基本操作
查看>>
mysql中的 +号 和 CONCAT(str1,str2,...)
查看>>
MySql中的concat()相关函数
查看>>
mysql中的concat函数,concat_ws函数,concat_group函数之间的区别
查看>>
MySQL中的count函数
查看>>
MySQL中的DB、DBMS、SQL
查看>>
MySQL中的DECIMAL类型:MYSQL_TYPE_DECIMAL与MYSQL_TYPE_NEWDECIMAL详解
查看>>