最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

本文實(shí)例為大家分享了用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()

更多精彩書單,請(qǐng)點(diǎn)擊python編程必備書單

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

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

相關(guān)文章

  • 基于Python實(shí)現(xiàn)火車票搶票軟件

    基于Python實(shí)現(xiàn)火車票搶票軟件

    每年的節(jié)假日一到,大家頭疼的總時(shí)同一個(gè)問題:你買到回家的票了嗎?尤其是大型的節(jié)日:國慶、春節(jié)等。本文將利用Python編寫一個(gè)火車票搶票軟件,感興趣的可以了解一下
    2022-07-07
  • Python實(shí)現(xiàn)輸入若干個(gè)正整數(shù),升序后輸出

    Python實(shí)現(xiàn)輸入若干個(gè)正整數(shù),升序后輸出

    這篇文章主要介紹了Python實(shí)現(xiàn)輸入若干個(gè)正整數(shù),升序后輸出方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-02-02
  • python中的列表與元組的使用

    python中的列表與元組的使用

    這篇文章主要介紹了python中的列表與元組的使用,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-08-08
  • Python學(xué)習(xí)小技巧之列表項(xiàng)的拼接

    Python學(xué)習(xí)小技巧之列表項(xiàng)的拼接

    這篇文章主要給大家介紹了Python學(xué)習(xí)小技巧之列表項(xiàng)的拼接的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起看看吧。
    2017-05-05
  • python3 使用traceback定位異常實(shí)例

    python3 使用traceback定位異常實(shí)例

    這篇文章主要介紹了python3 使用traceback定位異常實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-03-03
  • python實(shí)現(xiàn)AdaBoost算法的示例

    python實(shí)現(xiàn)AdaBoost算法的示例

    這篇文章主要介紹了python實(shí)現(xiàn)AdaBoost算法的示例,幫助大家更好的理解和了解機(jī)器學(xué)習(xí)算法,感興趣的朋友可以了解下
    2020-10-10
  • PyQt5編程擴(kuò)展之資源文件的使用教程

    PyQt5編程擴(kuò)展之資源文件的使用教程

    PyQt5支持Qt的資源系統(tǒng),這是用于在應(yīng)用程序中嵌入圖片和翻譯文件等資源的工具,下面這篇文章主要給大家介紹了關(guān)于PyQt5編程擴(kuò)展之資源文件使用的相關(guān)資料,文中通過圖文介紹的非常詳細(xì),需要的朋友可以參考下
    2023-03-03
  • Python之打印日志庫(logging)

    Python之打印日志庫(logging)

    這篇文章主要介紹了Python之打印日志庫(logging),具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-09-09
  • 詳解Python中time()方法的使用的教程

    詳解Python中time()方法的使用的教程

    這篇文章主要介紹了詳解Python中time()方法的使用的教程,是Python入門學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下
    2015-05-05
  • Python實(shí)現(xiàn)查找并刪除重復(fù)文件的方法小結(jié)

    Python實(shí)現(xiàn)查找并刪除重復(fù)文件的方法小結(jié)

    這篇文章主要為大家詳細(xì)介紹了如何使用Python編寫一個(gè)簡單的腳本來查找并刪除指定目錄及其子目錄中的重復(fù)文件,需要的可以參考一下
    2025-03-03

最新評(píng)論

雷山县| 乐昌市| 镇康县| 北海市| 泾川县| 科技| 平果县| 浪卡子县| 凤城市| 丹东市| 南安市| 南靖县| 绥中县| 朔州市| 玛多县| 色达县| 内黄县| 南靖县| 屯留县| 库尔勒市| 九龙县| 台中县| 新建县| 廊坊市| 双辽市| 镇雄县| 沅江市| 扎鲁特旗| 昌宁县| 龙海市| 新龙县| 苍南县| 紫阳县| 东源县| 龙井市| 横山县| 镇平县| 彰化市| 东山县| 腾冲县| 聂荣县|