如何在Python上畫個九角星


如何在Python上畫一個九角星

1.准備:Python 3.7和win10系統

2.打開Python IDLE界面,然后開始輸入代碼

參考代碼:

import turtle

turtle.pensize(2)
turtle.pencolor("yellow")
turtle.fillcolor("red")
turtle.begin_fill()
for i in range(9):
    turtle.forward(100)
 turtle.right(160)
    turtle.forward(100)
    turtle.left(120)
turtle.end_fill()
turtle.hideturtle()
turtle.done() 

3.測試代碼效果

 
預期效果:
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM