python如何实现生日快乐代码-Python教程

资源魔 51 0

python完成诞辰高兴代码的办法:起首要按【CTRL+R】键,cmd进入饬令行,输出pip install turtle装置第三方库;而后关上python IDE,将相干代码复制出来;最初按快捷键F5进行保留且执行便可。

python完成诞辰高兴代码的办法:

一、起首要CTRL+R而后cmd进入饬令行,输出pip install turtle装置第三方库

二、关上python IDE,以下图,点击“File",抉择”New File"

三、复制代码

#HappyBirthday
import turtle
import time
def move(angle,length):
    turtle.penup()
    turtle.seth(angle)
    turtle.fd(length)
#prepare
turtle.setup(1000,400,100,100)
turtle.penup()
turtle.fd(-350)
turtle.seth(90)
turtle.fd(50)
turtle.pendown()
turtle.pensize(10)
turtle.pencolor("green")
turtle.seth(0)
turtle.hideturtle()
turtle.speed(5)
#呀
turtle.fd(100)
#生
turtle.pencolor("green")
turtle.circle(50,90)
turtle.circle(50,-30)
turtle.seth(0)
turtle.fd(100)
turtle.fd(-50)
turtle.left(90)
turtle.fd(30)
turtle.fd(-60)
turtle.left(90)
turtle.fd(50)
turtle.fd(-100)
turtle.fd(50)
turtle.left(90)
turtle.fd(50)
turtle.right(90)
turtle.fd(60)
turtle.fd(-120)
#日
turtle.penup()
turtle.fd(-30)
turtle.pendown()
turtle.seth(90)
turtle.fd(100)
turtle.seth(0)
turtle.fd(70)
turtle.seth(-90)
turtle.fd(50)
turtle.seth(180)
turtle.fd(70)
turtle.seth(-90)
turtle.fd(50)
turtle.seth(0)
turtle.fd(70)
turtle.seth(90)
turtle.fd(50)
#挪动
move(0,30)
#快
turtle.pensize(8)
turtle.circle(30,15)
turtle.pendown()
turtle.circle(30,60)
turtle.penup()
turtle.seth(0)
turtle.fd(13)
turtle.seth(90)
turtle.pendown()
turtle.fd(40)
turtle.fd(-50)
turtle.penup()
turtle.seth(0)
turtle.fd(13)
turtle.pendown()
turtle.seth(-180)
turtle.circle(20,-90)
turtle.circle(20,90)
turtle.penup()
turtle.fd(13)
turtle.pendown()
turtle.seth(-90)
turtle.fd(60)
move(0,40)
move(90,80)
turtle.pendown()
turtle.seth(0)
turtle.fd(30)
turtle.seth(90)
turtle.fd(30)
turtle.fd(-30)
turtle.seth(0)
turtle.fd(20)
turtle.seth(-90)
turtle.fd(35)
turtle.seth(0)
turtle.fd(10)
turtle.fd(-30)
turtle.seth(90)
turtle.fd(35)
turtle.fd(-35)
turtle.seth(0)
turtle.fd(-25)
move(-90,50)
move(180,25)
turtle.pendown()
turtle.seth(0)
turtle.penup()
turtle.circle(50,20)
turtle.pendown()
turtle.circle(50,70)
turtle.seth(-90)
turtle.circle(50,60)
#挪动
move(0,50)
move(90,45)
#乐
turtle.pensize(10)
turtle.pendown()
turtle.fd(40)
turtle.seth(0)
turtle.circle(50,60)
turtle.circle(50,-25)
move(-90,15)
turtle.pendown()
turtle.fd(30)
turtle.seth(0)
turtle.fd(-25)
turtle.fd(65)
turtle.fd(-40)
turtle.seth(-90)
turtle.fd(60)
turtle.seth(135)
turtle.fd(20)
move(135,10)
turtle.pendown()
turtle.seth(-135)
turtle.fd(20)
move(0,70)
turtle.pendown()
turtle.seth(135)
turtle.fd(20)

四、按快捷键F5进行保留且执行,终极成果图以下:

相干收费学习保举:python视频教程

以上就是python若何完成诞辰高兴代码的具体内容,更多请存眷资源魔其它相干文章!

标签: Python python教程 python编程 python使用问题 生日快乐

抱歉,评论功能暂时关闭!