python实现生日快乐编程代码(生日蛋糕编程代码python)

网友投稿 6174 2022-08-18

python实现生日快乐编程代码(生日蛋糕编程代码python)

python实现生日快乐编程代码(生日蛋糕编程代码python)

用python实现生日快乐代码的方法:首先要按【CTRL+R】键,cmd进入命令行,输入pip install turtle安装第三方库;然后打开python IDE,将相关代码复制进去;最后按快捷键F5进行保存且执行即可。

python实现生日快乐代码的方法:

1、首先要CTRL+R然后cmd进入命令行,输入pip install turtle安装第三方库

2、打开python IDE,如下图,点击“File",选择”New File"

3.复制代码

#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)

4、按快捷键F5进行保存且执行,最终效果图如下:

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Python实现石头剪刀布编程代码(python编写石头剪刀布)
下一篇:python代码大全心形:一行Python代码画心型(python简单心形代码)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~