python画满屏玫瑰代码
时间: 2023-10-26 20:08:48 浏览: 223
以下是Python画满屏玫瑰的代码:
```python
import turtle
def draw_petal(t, r, angle):
for i in range(2):
t.circle(r, angle)
t.left(180-angle)
def draw_flower(t, n, r, angle):
for i in range(n):
draw_petal(t, r, angle)
t.left(360/n)
def draw_branch(t, len):
if len > 10:
t.forward(len)
t.right(20)
draw_branch(t, len-15)
t.left(40)
draw_branch(t, len-15)
t.right(20)
t.backward(len)
def main():
t = turtle.Turtle()
t.speed(0)
t.color("red")
t.penup()
t.goto(0, -200)
t.pendown()
draw_flower(t, 10, 100, 30)
t.penup()
t.goto(0, 0)
t.pendown()
t.color("brown")
draw_branch(t, 100)
turtle.done()
if __name__ == "__main__":
main()
```
阅读全文