本文实例为大家分享了用python画一朵花的具体代码,供大家参考,具体内容如下

第一种,画法

from turtle import *

import time

setup(600,800,0,0)

speed(0)

penup()

seth(90)

fd(340)

seth(0)

pendown()

speed(5)

begin_fill()

fillcolor('red')

circle(50,30)

for i in range(10):

fd(1)

left(10)

circle(40,40)

for i in range(6):

fd(1)

left(3)

circle(80,40)

for i in range(20):

fd(0.5)

left(5)

circle(80,45)

for i in range(10):

fd(2)

left(1)

circle(80,25)

for i in range(20):

fd(1)

left(4)

circle(50,50)

time.sleep(0.1)

circle(120,55)

speed(0)

seth(-90)

fd(70)

right(150)

fd(20)

left(140)

circle(140,90)

left(30)

circle(160,100)

left(130)

fd(25)

penup()

right(150)

circle(40,80)

pendown()

left(115)

fd(60)

penup()

left(180)

fd(60)

pendown()

end_fill()

right(120)

circle(-50,50)

circle(-20,90)

speed(1)

fd(75)

speed(0)

circle(90,110)

penup()

left(162)

fd(185)

left(170)

pendown()

circle(200,10)

circle(100,40)

circle(-52,115)

left(20)

circle(100,20)

circle(300,20)

speed(1)

fd(250)

penup()

speed(0)

left(180)

fd(250)

circle(-300,7)

right(80)

circle(200,5)

pendown()

left(60)

begin_fill()

fillcolor('green')

circle(-80,100)

right(90)

fd(10)

left(20)

circle(-63,127)

end_fill()

penup()

left(50)

fd(20)

left(180)

pendown()

circle(200,25)

penup()

right(150)

fd(180)

right(40)

pendown()

begin_fill()

fillcolor('green')

circle(-100,80)

right(150)

fd(10)

left(60)

circle(-80,98)

end_fill()

penup()

left(60)

fd(13)

left(180)

pendown()

speed(1)

circle(-200,23)

exitonclick()

第二种,画法

import turtle

import math

def p_line(t, n, length, angle):

"""Draws n line segments."""

for i in range(n):

t.fd(length)

t.lt(angle)

def polygon(t, n, length):

"""Draws a polygon with n sides."""

angle = 360 / n

p_line(t, n, length, angle)

def arc(t, r, angle):

"""Draws an arc with the given radius and angle."""

arc_length = 2 * math.pi * r * abs(angle) / 360

n = int(arc_length / 4) + 1

step_length = arc_length / n

step_angle = float(angle) / n

# Before starting reduces, making a slight left turn.

t.lt(step_angle / 2)

p_line(t, n, step_length, step_angle)

t.rt(step_angle / 2)

def petal(t, r, angle):

"""Draws a 花瓣 using two arcs."""

for i in range(2):

arc(t, r, angle)

t.lt(180 - angle)

def flower(t, n, r, angle, p):

"""Draws a flower with n petals."""

for i in range(n):

petal(t, r, angle)

t.lt(p / n)

def leaf(t, r, angle, p):

"""Draws a 叶子 and fill it."""

t.begin_fill() # Begin the fill process.

t.down()

flower(t, 1, r, angle, p)

t.end_fill()

def main():

window = turtle.Screen() # creat a screen

window.bgcolor("white")

window.title("draw a flower")

lucy = turtle.Turtle()

lucy.shape("turtle")

lucy.color("red")

lucy.width(3)

# lucy.speed(10)

# Drawing flower

flower(lucy, 7, 60, 100, 360)

# Drawing pedicel

lucy.color("brown")

lucy.rt(90)

lucy.fd(200)

# Drawing leaf 1

lucy.width(1)

lucy.rt(270)

lucy.color("green")

leaf(lucy, 40, 80, 180)

lucy.rt(140)

lucy.color("black")

lucy.fd(30)

lucy.lt(180)

lucy.fd(30)

# Drawing leaf 2

lucy.rt(120)

lucy.color("green")

leaf(lucy, 40, 80, 180)

lucy.color("black")

lucy.rt(140)

lucy.fd(30)

lucy.ht() # hideturtle

window.exitonclick()

main()

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

怎么python画好几朵玫瑰花_教你使用python画一朵花送女朋友相关推荐

  1. 如何用python画一朵花_教你使用python画一朵花送女朋友

    本文实例为大家分享了用python画一朵花的具体代码,供大家参考,具体内容如下 第一种,画法 from turtle import * import time setup(600,800,0,0) s ...

  2. 怎么样用python画一朵花_教你使用python画一朵花送女朋友

    本文实例为大家分享了用python画一朵花的具体代码,供大家参考,具体内容如下 第一种,画法 from turtle import * import time setup(600,800,0,0) s ...

  3. python画动态爱心代码_教你用python画动态爱心表白

    原标题:教你用python画动态爱心表白 初级画心 学Python,感觉你们的都好复杂,那我来个简单的,我是直接把心形看作是一个正方形+两个半圆: 于是这就很简单了,十行代码解决: import tu ...

  4. 使用python 处理表格生成图表_教你用Python自动读取数据生成图表,产生的效益很可观...

    厌烦了每次都要在Excel里拖动数据来生成图形吧,这篇文章里,教你用Python自动读取Excel数据生成图表,然后Python 使用XlsxWriter模块在Excel工作表中绘制带有数据表的柱形图 ...

  5. python利用自动识别写模块_教你用Python 实现自动导入缺失的库

    在写 Python 项目的时候,我们可能经常会遇到导入模块失败的错误:ImportError: No module named 'xxx' 或者 ModuleNotFoundError: No mod ...

  6. python画易烊千玺_教你如何轻松画出逼真的易烊千玺

    喜欢TFBOYS千玺好久了,作为粉都有种想给他画同人的冲动,前几天发现一个超简单的画画教程,昨天就悄悄画了一幅画,发到朋友圈,总共103个赞,连老师都来点了赞,66666666,今天把教程分享出来,不 ...

  7. python的界面文字翻译_教你用Python实现微信翻译机器人

    相信大家在日常学习或者是阅读英文文章的过程中,难免会出现几个不认识的单词,或者想快速翻译某段英文的意思. 今天,利用Python爬虫等知识,教大家打造一个微信下的翻译小助手.好吧,开始干活. 先来看看 ...

  8. python我的所得税计算器_教你使用Python实现新个税计算器

    自从采用新个税计算方法后,每个月发工资你是否真的清楚扣多少税? 今天跟大家分享下如何计算,希望大家喜欢. 计税方法科普 个税方法 这里需要知道的知识点: 1.个税起征点调到 5000; 2.累积预扣法 ...

  9. python设计拼图小游戏_教你用Python自制拼图小游戏,轻松搞定熊孩子

    摘要:本文主要为大家详细介绍了python实现拼图小游戏,文中还有示例代码介绍,感兴趣的小伙伴们可以参考一下. 开发工具 Python版本:3.6.4 相关模块: pygame模块: 以及一些Pyth ...

最新文章

  1. boost::asio异步模式的C/S客户端源码实现
  2. java字符匹配,Java:匹配字符串中的短语
  3. 净核心vs节点js您应该选择什么
  4. 电脑边充电边用好吗_平板电脑充电推车厂家哪家好?
  5. JAVA复习5(集合——集合的遍历 Iteratorforeach、Enumeration——HashMap、HashTable、LinkedHashMap——map的遍历)
  6. 系统即将关机请保存关机是由nt_设置Windows电脑自动关机
  7. Bash脚本报错:“/bin/bash^M: bad interpreter: No such file or directory”
  8. 2017蓝桥杯决赛-发现环 数据结构|搜索
  9. 热榜!基于jsp+mysql的JSP在线水果销售商城系统设计实现【建议收藏】
  10. 在linux服务器搭建函数,linux ftp服务器搭建
  11. JS+CSS实现弹出全屏灰黑色透明遮罩效果的方法
  12. 机械制造技术基础【4】
  13. LaTeX Studio下载安装
  14. 干货分享:常见的十种破解密码方法!赶紧收藏!
  15. 使用vue-router却导致页面空白无法呈现-报错?
  16. bind peeking--绑定变量窥视
  17. nodepad++之jsonviewer插件
  18. 赵小楼:《天道》《遥远的救世主》深度解析(28)人文意识发展到今天,我们应该怎么改变?
  19. 移动设备技术_手机底层板子设计人员告诉你一般手机电池的正确使用方法
  20. 【Python教程】史上最全Python快速入门教程,满满都是干货

热门文章

  1. AMD推出用于工作站PC的64核心Threadripper Pro
  2. 谷粒商城分布式基础和对应的环境搭建
  3. Python学习笔记3—第3章 列表简介
  4. 同城跑腿小程序怎么做
  5. linux wifi驱动分析,REL8192EU wifi linux驱动安装详解
  6. python随机数不重复_Python产生一个数值范围内的不重复的随机数的实现方法
  7. idea修改背景为护眼背景模式、淡黄色、淡绿色等,内附多张纯色背景图片供使用
  8. 游戏网站源码_远征游戏网站源码 discuz内核
  9. linux下的电子仿真软件,立创EDA Linux版
  10. 数据分析方法和思维—相关性分析法