亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

教你使用python畫一朵花送女朋友

 更新時間:2018年03月29日 10:11:48   作者:Ly_ox  
這篇文章主要為大家講解如何使用python畫一朵花,送女朋友,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了用python畫一朵花的具體代碼,供大家參考,具體內(nèi)容如下

第一種,畫法

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編程必備書單

領(lǐng)取干貨:零基礎(chǔ)入門學習python視頻教程

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 使用Python編寫vim插件的簡單示例

    使用Python編寫vim插件的簡單示例

    這篇文章主要介紹了使用Python編寫vim插件的簡單教程,文中舉了一個獲取reddit首頁信息并顯示在緩沖區(qū)中的例子,需要的朋友可以參考下
    2015-04-04
  • appium測試之APP元素定位及基本工具介紹

    appium測試之APP元素定位及基本工具介紹

    看了我文章了相信都了解了web端的元素定位了,沒看的,既然進來了那么肯定多多少少知道些,本文主要來介紹APP的元素定位有哪些定位方式,我們又怎么去連接APP,然后通過工具去獲取元素
    2021-09-09
  • Python實現(xiàn)將Markdown文檔轉(zhuǎn)為EPUB電子書文件

    Python實現(xiàn)將Markdown文檔轉(zhuǎn)為EPUB電子書文件

    這篇文章主要為大家詳細介紹了Python如何實現(xiàn)將Markdown文檔轉(zhuǎn)為EPUB電子書文件,文中的示例代碼講解詳細,感興趣的小伙伴可以了解一下
    2023-06-06
  • centos6.8安裝python3.7無法import _ssl的解決方法

    centos6.8安裝python3.7無法import _ssl的解決方法

    這篇文章主要介紹了centos6.8安裝python3.7無法import _ssl的解決方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-09-09
  • 剖析Python的Twisted框架的核心特性

    剖析Python的Twisted框架的核心特性

    這篇文章主要介紹了剖析Python的Twisted框架的核心特性,包括Twisted框架中reacter與Deferred等的關(guān)鍵用法,需要的朋友可以參考下
    2016-05-05
  • Numpy數(shù)組array和矩陣matrix轉(zhuǎn)換方法

    Numpy數(shù)組array和矩陣matrix轉(zhuǎn)換方法

    這篇文章主要介紹了Numpy數(shù)組array和矩陣matrix轉(zhuǎn)換方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2019-08-08
  • python連接讀寫操作redis的完整代碼實例

    python連接讀寫操作redis的完整代碼實例

    這篇文章主要介紹了python連接讀寫操作redis的完整代碼實例,包括redis連接與讀寫操作,redis-sentinel哨兵模式下Python操作redis,redis-cluster(集群)模式下Python操作redis,需要的朋友可以參考下
    2023-01-01
  • 解決pycharm py文件運行后停止按鈕變成了灰色的問題

    解決pycharm py文件運行后停止按鈕變成了灰色的問題

    今天小編就為大家分享一篇解決pycharm py文件運行后停止按鈕變成了灰色的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-11-11
  • 使用Python實現(xiàn)從零開始打造一個三維繪圖系統(tǒng)

    使用Python實現(xiàn)從零開始打造一個三維繪圖系統(tǒng)

    這篇文章主要為大家詳細介紹了如何使用Python實現(xiàn)一個繪圖系統(tǒng),通過指定x,y,z的表達式,以實現(xiàn)三維繪圖的目的,感興趣的可以了解下
    2024-02-02
  • protobuf 序列化和反序列化操作流程

    protobuf 序列化和反序列化操作流程

    Protocol Buffers(protobuf)是一種輕量級的數(shù)據(jù)交換格式,可以用于結(jié)構(gòu)化數(shù)據(jù)的序列化和反序列化,它使用二進制格式來編碼數(shù)據(jù),以提高傳輸效率和數(shù)據(jù)壓縮比,這篇文章主要介紹了protobuf 序列化和反序列化操作流程,需要的朋友可以參考下
    2024-06-06

最新評論