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

如何用Python畫一些簡單形狀你知道嗎

 更新時(shí)間:2021年08月17日 11:13:58   作者:我?guī)浀氖遣皇菬o可救藥  
這篇文章主要介紹了用Python作圖的一個(gè)簡單實(shí)例,通過turtle模塊實(shí)現(xiàn)作圖,具有一定參考價(jià)值,需要的朋友可以了解下希望能給你帶來幫助

進(jìn)入主題

1.

import turtle as t
import math
t.pensize(3)
t.tracer(10)
t.hideturtle()
start_x = -200
for y in range(-150,150,5):
    t.penup()
    t.goto(start_x,y)
    t.pendown()
    for x in range(-200,200,1):
        if ((y-50*(math.cos(0.05*x)) <= 80) and
            (y-50*(math.cos(0.05*x)) >= 60)):
            t.pencolor('yellow')
        elif ((y-50*(math.cos(0.05*x)) <= 40) and
            (y-50*(math.cos(0.05*x)) >= -20)):
            t.pencolor('blue')
        elif ((y-50*(math.cos(0.05*x)) <= -20) and
            (y-50*(math.cos(0.05*x)) >= -80)):
            t.pencolor('red')
        elif ((y-50*(math.cos(0.05*x)) <= -60) and
            (y-50*(math.cos(0.05)) <= -80)):
            t.pencolor('green')
        else:
            t.pencolor('black')
        t.setx(x)
t.update()
t.done()

import turtle as t
t.speed(0)
t.tracer(20)
t.hideturtle()
t.colormode(255)
angle = 90
for x in range(255,0,-5):
    for n in range(360//angle):
        t.pencolor((x,255,255))
        t.fillcolor((25,x,255))
        t.begin_fill()
        for i in range(2):
            t.forward(x)
            t.right(angle)
            t.forward(x)
            t.right(180-angle)
        t.end_fill()
        t.right(angle)
t.update()
t.done()

import turtle as t
t.speed(0)
t.tracer(20)
t.colormode(255)
angle = 60
angle2 = 3
for x in range(255,0,-5):
    for n in range(360//angle):
        t.pencolor((x,255,255))
        t.fillcolor((255,x,255))
        t.begin_fill()
        for i in range(2):
            t.forward(x)
            t.right(angle)
            t.forward(x)
            t.right(180-angle)
        t.end_fill()
        t.right(angle)
    t.right(angle2)
t.update()
t.done()

from turtle import *       
colormode(255)
tracer(5)
a1=39
a2=1
for x in range(255,0,-5):
    pencolor(x,255,255)
    fillcolor(255,x,255)
    for y in range(360//a1):
        begin_fill()
        for z in range(2):
            fd(x)
            rt(a1)
            fd(x)
            rt(180-a1)
        end_fill()
        rt(a1)
    rt(a2)
update()
ht()
done()

import turtle as t
t.speed(0)
t.hideturtle()
t.penup()
t.setx(-200)
t.pendown()
r = 20
i = 6
for x in range(10):
    if x % 2 == 0:
        t.fillcolor("skyblue")
        t.begin_fill()
        t.circle(r)
        t.end_fill()
        add = 0
    else:
        t.fillcolor("green")
        t.begin_fill()
        for n in range(4):
            t.forward(r*2)
            t.left(90)
        t.end_fill()
        add = r*2
    t.penup()
    t.forward(r+i+add)
    t.pendown()
t.done()

import turtle as t
t.pensize(5)
t.tracer(10)
t.hideturtle()
start_x = -200
for y in range(-150,150,20):
    t.penup()
    t.goto(start_x,y)
    t.pendown()
    for x in range(-200,200,1):
        if ((x < 100 and x > 0) and 
            (y < 80 and y > 0)):
            t.pencolor('yellow')
        elif ((x < 100 and x > 0) and
            (y < 0 and y > -80)):
            t.pencolor('blue')
        elif ((x < 0 and x > -100) and
            (y < 80 and y > 0)):
            t.pencolor('red')
        elif ((x < 0 and x > -100) and
            (y < 0 and y > -80)):
            t.pencolor('orange')
        else:
            t.pencolor('green')
        t.setx(x)
t.update()
t.done()

import turtle as t
t.pensize(5)
t.tracer(10)
t.hideturtle()
start_x = -200
for y in range(-150,150,20):
    t.penup()
    t.goto(start_x,y)
    t.pendown()
    for x in range(-200,200,1):
        if ((y-x <= 40) and
            (y-x >= -40)):
            t.pencolor('yellow')
        elif ((y+x <= 40) and
            (y+x >= -40)):
            t.pencolor('blue')
        else:
            t.pencolor('green')
        t.setx(x)
t.update()
t.done()

import turtle as t
t.speed(0)
t.tracer(20)
t.hideturtle()
t.colormode(255)
angle = 60
for x in range(255,0,-5):
    for n in range(360//angle):
        t.pencolor((x,255,255))
        t.fillcolor((255,x,255))
        t.begin_fill()
        for i in range(2):
            t.forward(x)
            t.right(angle)
            t.forward(x)
            t.right(180-angle)
        t.end_fill()
        t.right(angle)
t.update()
t.done()

總結(jié)

本篇文章就到這里了,希望能給你帶來幫助,也希望您能夠多多關(guān)注腳本之家的更多內(nèi)容!

相關(guān)文章

  • python抓取網(wǎng)頁內(nèi)容示例分享

    python抓取網(wǎng)頁內(nèi)容示例分享

    這篇文章主要介紹了python抓取網(wǎng)頁內(nèi)容示例,在抓取的時(shí)候?qū)τ趃bk編碼網(wǎng)頁還需要轉(zhuǎn)化一下,具體看下面的示例吧
    2014-02-02
  • python實(shí)現(xiàn)的分析并統(tǒng)計(jì)nginx日志數(shù)據(jù)功能示例

    python實(shí)現(xiàn)的分析并統(tǒng)計(jì)nginx日志數(shù)據(jù)功能示例

    這篇文章主要介紹了python實(shí)現(xiàn)的分析并統(tǒng)計(jì)nginx日志數(shù)據(jù)功能,結(jié)合實(shí)例形式分析了Python針對(duì)nginx日志ip、訪問url、狀態(tài)等數(shù)據(jù)的相關(guān)讀取、解析操作技巧,需要的朋友可以參考下
    2019-12-12
  • Sanic框架流式傳輸操作示例

    Sanic框架流式傳輸操作示例

    這篇文章主要介紹了Sanic框架流式傳輸操作,結(jié)合實(shí)例形式分析了Sanic通過流請(qǐng)求與響應(yīng)傳輸操作相關(guān)實(shí)現(xiàn)技巧與注意事項(xiàng),需要的朋友可以參考下
    2018-07-07
  • 淺談keras保存模型中的save()和save_weights()區(qū)別

    淺談keras保存模型中的save()和save_weights()區(qū)別

    這篇文章主要介紹了淺談keras保存模型中的save()和save_weights()區(qū)別,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-05-05
  • opencv?傅里葉變換的實(shí)現(xiàn)

    opencv?傅里葉變換的實(shí)現(xiàn)

    本文主要介紹了opencv?傅里葉變換,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧<BR>
    2022-06-06
  • python中isdigit() isalpha()用于判斷字符串的類型問題

    python中isdigit() isalpha()用于判斷字符串的類型問題

    這篇文章主要介紹了python中isdigit() isalpha()用于判斷字符串的類型問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-11-11
  • 老生常談Python startswith()函數(shù)與endswith函數(shù)

    老生常談Python startswith()函數(shù)與endswith函數(shù)

    下面小編就為大家?guī)硪黄仙U凱ython startswith()函數(shù)與endswith函數(shù)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-09-09
  • Python爬取讀者并制作成PDF

    Python爬取讀者并制作成PDF

    本文是在學(xué)習(xí)了beautifulsoup之后,制作的一個(gè)爬取讀者雜志并使用reportlab制作成pdf的python小工具,咱也文藝一下:),分享給大家,有需要的小伙伴參考下吧。
    2015-03-03
  • Python使用multiprocessing如何實(shí)現(xiàn)多進(jìn)程

    Python使用multiprocessing如何實(shí)現(xiàn)多進(jìn)程

    這篇文章主要介紹了Python使用multiprocessing如何實(shí)現(xiàn)多進(jìn)程問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-02-02
  • python實(shí)現(xiàn)將range()函數(shù)生成的數(shù)字存儲(chǔ)在一個(gè)列表中

    python實(shí)現(xiàn)將range()函數(shù)生成的數(shù)字存儲(chǔ)在一個(gè)列表中

    這篇文章主要介紹了python實(shí)現(xiàn)將range()函數(shù)生成的數(shù)字存儲(chǔ)在一個(gè)列表中,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2020-04-04

最新評(píng)論

韩城市| 大同县| 黔西| 锡林浩特市| 方山县| 舟山市| 三台县| 拉孜县| 玛沁县| 荣昌县| 和平县| 荣昌县| 吉林省| 轮台县| 上蔡县| 浙江省| 忻州市| 定西市| 潮州市| 阳信县| 剑阁县| 陕西省| 广丰县| 和顺县| 红安县| 腾冲县| 新平| 抚顺市| 荆门市| 丘北县| 资源县| 兴文县| 赤水市| 肥乡县| 城固县| 凤庆县| 凤凰县| 清流县| 常州市| 泽库县| 青海省|