turtle库基础练习

1.画一组同切圆

>>> import turtle
>>> turtle.circle(10)
>>> turtle.circle(20)
>>> turtle.circle(30)

2.画一组同心圆

import turtle

for i in range(5):
    turtle.up()
    turtle.goto(0,-25*(i+1))
    turtle.down()
    turtle.circle(25*(i+1))

3.画一个五角星

>>> import turtle
>>> turtle.color('yellow')
>>> turtle.bgcolor('red')
>>> turtle.hideturtle()
>>> turtle.beginfill()
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    turtle.beginfill()
AttributeError: module 'turtle' has no attribute 'beginfill'
>>> turtle.begin_fill()
>>> turtle.forward(99)
>>> turtle.right(144)
>>> turtle.forward(99)
>>> turtle.right(144)
>>> turtle.forward(99)
>>> turtle.right(144)
>>> turtle.forward(99)
>>> turtle.right(144)
>>> turtle.forward(99)
>>> turtle.end_fill()

4.画一个黄色实心五角星

>>> import turtle
>>> turtle.color('yellow')
>>> turtle.bgcolor('red')
>>> turtle.hideturtle()
>>> turtle.beginfill()
Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    turtle.beginfill()
AttributeError: module 'turtle' has no attribute 'beginfill'
>>> turtle.begin_fill()
>>> turtle.forward(99)
>>> turtle.right(144)
>>> turtle.forward(99)
>>> turtle.right(144)
>>> turtle.forward(99)
>>> turtle.right(144)
>>> turtle.forward(99)
>>> turtle.right(144)
>>> turtle.forward(99)
>>> turtle.end_fill()

5.画左上角的五颗五角星

import turtle

turtle.setup(600,400,0,0)
turtle.color('yellow')
turtle.bgcolor('red')
turtle.fillcolor('yellow')

def mygoto(x,y):
    turtle.up()
    turtle.goto(x,y)
    turtle.down()
    
mygoto(-250,75)
turtle.begin_fill()
for i in range(5):
    turtle.forward(100)
    turtle.right(144)
turtle.end_fill()

mygoto(-100,150)
turtle.begin_fill()
for i in range(5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()

mygoto(-80,80)
turtle.begin_fill()
for i in range(5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()

mygoto(-70,20)
turtle.begin_fill()
for i in range(5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()

mygoto(-80,-40)
turtle.begin_fill()
for i in range(5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()

 

转载于:https://www.cnblogs.com/xiepingjian/p/7509302.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值