Python入门基础009—海龟画图

1.四个连环的圆

import turtle as t
t.speed(0)#调节速度,0是最快的
t.color('blue')
t.pensize(9)#调节字符粗细
for i in range(0,20):
    t.right(91)
    t.circle(100)
t.done()

2.奥运五环

import turtle
turtle.width(10)#指定画笔的粗细
turtle.speed(10)#调剂速度
#第一个蓝色的圆
turtle.color("blue")
turtle.circle(50)
#第二个黑色的圆
turtle.penup()#抬笔
turtle.goto(120,0)#圆与圆的距离为20
turtle.pendown()#落笔
turtle.color("black")
turtle.circle(50)

turtle.penup()
turtle.goto(240,0)
turtle.pendown()
turtle.color("red")
turtle.circle(50)

turtle.penup()
turtle.goto(60,-50)
turtle.pendown()
turtle.color("green")
turtle.circle(50)

turtle.penup()
turtle.goto(180,-50)
turtle.pendown()
turtle.color("yellow")
turtle.circle(50)

turtle.done()

 

3.美国队长

#1.画一个红色的圆圈
import turtle as t
t.color('white')
t.speed(0)
t.penup()
t.goto(0,-200)
t.pendown()

t.begin_fill()#填充一个红色圆
t.circle(200)
t.color('red')
t.end_fill()

#填充白色在一个环里面
t.penup()
t.goto(0,-150)
t.pendown()
t.begin_fill()
t.circle(150)
t.color('white')
t.end_fill()

#填充蓝色的环
t.penup()
t.goto(0,-100)
t.pendown()
t.begin_fill()
t.circle(100)
t.color('blue')
t.end_fill()
#画五角星
t.penup()
t.color('white')
t.goto(-70,10)
t.pendown()
t.begin_fill()
for i in range(5):
    t.forward(140)#向前走140米
    t.right(144)
t.end_fill()
t.hideturtle()#隐藏箭头
t.done()

 

4. 气球

import turtle as t
import random #随机数
t.colormode(255)
t.speed(0)
for i in range(20):
    red=random.randint(0,255)#0--255的颜色随机选
    green=random.randint(0,255)
    blue=random.randint(0,255)

    x=random.randint(-400,220)#坐标随机
    y=random.randint(-400,220)#坐标随机

    t.penup()
    t.goto(x,y)
    t.pendown()


    t.begin_fill()
    t.circle(50)
    t.color(red,green,blue)#三种随机颜色
    t.end_fill()
    t.right(90)
    t.forward(90)
    t.left(90)
t.done()

 

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值