• Python使用turtle画五环和糖葫芦


    画五环

    import turtle           # 导入turtle库
    turtle.width(10)        # 设置画笔粗细为10
    turtle.color("blue")    # 设置画笔颜色为‘蓝色·’
    turtle.circle(50)       # 画圆半径为50
    turtle.penup()          # 抬起画笔
    turtle.goto(120, 0)     # 绝对坐标turtle.goto(x,y)
    turtle.color("black")   # 设置画笔颜色为黑色
    turtle.pendown()        # 下笔
    turtle.circle(50)       #画圆半径为50
    turtle.penup()          #抬笔
    turtle.goto(240, 0)     #坐标(x,y)
    turtle.color("red")     #画笔颜色:红色
    turtle.pendown()        #下笔
    turtle.circle(50)       #画圆半径:50
    turtle.penup()          #抬笔
    turtle.goto(60, -45)    #坐标(x,y)
    turtle.color("yellow")  #颜色:黄色
    turtle.pendown()        #下笔
    turtle.circle(50)       #画圆半径:50
    turtle.penup()          #抬笔
    turtle.goto(180, -45)   #坐标(x,y)
    turtle.color("green")   #画笔颜色:绿色
    turtle.pendown()        #下笔
    turtle.circle(50)       #圆半径:50
    
    

    在这里插入图片描述

    画糖葫芦

    import turtle   #导入模块
    t=turtle.Pen()  #创建画笔
    t.penup()       #提起画笔
    t.goto(20, 0)   #起始坐标
    t.pendown()     #下笔
    t.begin_fill()  #填充颜色
    t.fillcolor("red")#填充红色
    t.circle(40)       #画圆半径:40
    t.end_fill()    #结束填充
    
    t.penup()
    t.goto(60,40)
    t.pendown()
    t.begin_fill()
    t.fillcolor("blue")
    t.circle(40)
    t.end_fill()
    
    t.penup()
    t.goto(100,80)
    t.pendown()
    t.begin_fill()
    t.fillcolor("yellow")
    t.circle(40)
    t.end_fill()
    
    t.penup()
    t.goto(140,120)
    t.pendown()
    t.begin_fill()
    t.fillcolor("purple")
    t.circle(40)
    t.end_fill()
    
    t.penup()
    t.speed(1)
    t.width(5)
    t.color('orange')
    t.goto(-60,-40)
    t.pendown()
    t.seth(45)	#45°角
    t.forward(350)
    
    turtle.exitonclick()    #画完之后,停留画布,点击退出
    
    
    
    
    
  • 相关阅读:
    笛卡尔积
    Oracle语句以及各种知识点
    vue和angular的区别:
    vue的生命周期的理解
    使用递归实现一个数组的快速排序
    对css盒模型的理解
    对 超链接 的理解
    HTML语义化的理解
    HTML 、XHTML、H5的区别:
    mysql的使用相关问题
  • 原文地址:https://www.cnblogs.com/James-221/p/13647434.html
Copyright © 2020-2023  润新知