python生日蛋糕代码(python制作超炫流星雨表白)
python生日蛋糕代码
python生日蛋糕代码是importturtleast。
python实现生日快乐代码的方法:首先要按【CTRL+R】键,cmd进入命令行,输入pipinstallturtle安装第三方库;然后打开pythonIDE,将相关代码复制进去;最后按快捷键F5进行保存且执行即可。
代码就是程序员用开发工具所支持的语言写出来的源文件,是一组由字符、符号或信号码元以离散形式表示信息的明确的规则体系。
python父亲节代码
python父亲节代码如下:
飞吻:____、kissesandhugs、baci、cium(印尼版“么么哒”)、Besos(西班牙版“亲亲”)、XOXO、么么哒、亲亲蛋糕:_______________、happybirthday、生日快乐、birthday星星雨:______、missu、想你了、我想你、Teechodemenos(西班牙版“想你”)火苗:红红火火爆竹:新年快乐钱袋:恭喜发财,招财进宝星星:吉星高照,福星高照。
先写下对父亲想说的话,用split()函数按空格切割成单独的词;然后根据心形函数使用循环语句,一行一行打印,在函数内部分别打印每个词,函数外部打印空格;最后,每个单词对应的心形图案会依次运行显示出来。
用Python的turtle模块画生日蛋糕
import?turtle?as?t
import?math?as?m
import?random?as?r
t.speed(10)
def?drawX(a,?i):
????angle?=?m.radians(i)
????return?a?*?m.cos(angle)
def?drawY(b,?i):
????angle?=?m.radians(i)
????return?b?*?m.sin(angle)
#?设置背景颜色,窗口位置以及大小
t.bgcolor("#d3dae8")
t.setup(1000,?800)
t.penup()
t.goto(150,?0)
t.pendown()
#?1
t.pencolor("white")
t.begin_fill()
for?i?in?range(360):
????x?=?drawX(150,?i)
????y?=?drawY(60,?i)
????t.goto(x,?y)
t.fillcolor("#fef5f7")
t.end_fill()
#?2
t.begin_fill()
for?i?in?range(180):
????x?=?drawX(150,?-i)
????y?=?drawY(70,?-i)
????t.goto(x,?y)
for?i?in?range(180,?360):
????x?=?drawX(150,?i)
????y?=?drawY(60,?i)
????t.goto(x,?y)
t.fillcolor("#f2d7dd")
t.end_fill()
#?3
t.pu()
t.goto(120,?0)
t.pd()
t.begin_fill()
for?i?in?range(360):
????x?=?drawX(120,?i)
????y?=?drawY(48,?i)
????t.goto(x,?y)
t.fillcolor("#cbd9f9")
t.end_fill()
#?4
t.begin_fill()
t.pencolor("#fee48c")
for?i?in?range(540):
????x?=?drawX(120,?i)
????y?=?drawY(48,?i)?+?70
????t.goto(x,?y)
t.goto(-120,?0)
t.fillcolor("#cbd9f9")
t.end_fill()
#?5
t.pu()
t.goto(120,?70)
t.pd()
t.pencolor("#fff0f3")
t.begin_fill()
for?i?in?range(360):
????x?=?drawX(120,?i)
????y?=?drawY(48,?i)?+?70
????t.goto(x,?y)
t.fillcolor("#fff0f3")
t.end_fill()
#?6
t.pu()
t.goto(110,?70)
t.pd()
t.pencolor("#fff9fb")
t.begin_fill()
for?i?in?range(360):
????x?=?drawX(110,?i)
????y?=?drawY(44,?i)?+?70
????t.goto(x,?y)
t.fillcolor("#fff9fb")
t.end_fill()
#?7
t.pu()
t.goto(120,?0)
t.pd()
t.begin_fill()
t.pencolor("#ffa79d")
for?i?in?range(180):
????x?=?drawX(120,?-i)
????y?=?drawY(48,?-i)?+?10
????t.goto(x,?y)
t.goto(-120,?0)
for?i?in?range(180,?360):
????x?=?drawX(120,?i)
????y?=?drawY(48,?i)
????t.goto(x,?y)
t.fillcolor("#ffa79d")
t.end_fill()
#?8
t.pu()
t.goto(120,?70)
t.pd()
t.begin_fill()
t.pensize(4)
t.pencolor("#fff0f3")
for?i?in?range(1800):
????x?=?drawX(120,?0.1?*?i)
????y?=?drawY(-18,?i)?+?10
????t.goto(x,?y)
t.goto(-120,?70)
t.pensize(1)
for?i?in?range(180,?360):
????x?=?drawX(120,?i)
????y?=?drawY(48,?i)?+?70
????t.goto(x,?y)
t.fillcolor("#fff0f3")
t.end_fill()
#?9
t.pu()
t.goto(80,?70)
t.pd()
t.begin_fill()
t.pencolor("#6f3732")
t.goto(80,?120)
for?i?in?range(180):
????x?=?drawX(80,?i)
????y?=?drawY(32,?i)?+?120
????t.goto(x,?y)
t.goto(-80,?70)
for?i?in?range(180,?360):
????x?=?drawX(80,?i)
????y?=?drawY(32,?i)?+?70
????t.goto(x,?y)
t.fillcolor("#6f3732")
t.end_fill()
#?10
t.pu()
t.goto(80,?120)
t.pd()
t.pencolor("#ffaaa0")
t.begin_fill()
for?i?in?range(360):
????x?=?drawX(80,?i)
????y?=?drawY(32,?i)?+?120
????t.goto(x,?y)
t.fillcolor("#ffaaa0")
t.end_fill()
#?11
t.pu()
t.goto(70,?120)
t.pd()
t.pencolor("#ffc3be")
t.begin_fill()
for?i?in?range(360):
????x?=?drawX(70,?i)
????y?=?drawY(28,?i)?+?120
????t.goto(x,?y)
t.fillcolor("#ffc3be")
t.end_fill()
#?12
t.pu()
t.goto(80,?120)
t.pd()
t.begin_fill()
t.pensize(3)
t.pencolor("#ffaaa0")
for?i?in?range(1800):
????x?=?drawX(80,?0.1?*?i)
????y?=?drawY(-12,?i)?+?80
????t.goto(x,?y)
t.goto(-80,?120)
t.pensize(1)
for?i?in?range(180,?360):
????x?=?drawX(80,?i)
????y?=?drawY(32,?i)?+?120
????t.goto(x,?y)
t.fillcolor("#ffaaa0")
t.end_fill()
#?13
t.pu()
t.goto(64,?120)
t.pd()
t.pencolor("#b1c9e9")
t.begin_fill()
for?i?in?range(360):
????x?=?drawX(4,?i)?+?60
????y?=?drawY(1,?i)?+?120
????t.goto(x,?y)
t.goto(64,?170)
for?i?in?range(540):
????x?=?drawX(4,?i)?+?60
????y?=?drawY(1,?i)?+?170
????t.goto(x,?y)
t.goto(56,?120)
t.fillcolor("#b1c9e9")
t.end_fill()
t.pencolor("white")
t.pensize(2)
for?i?in?range(1,?6):
????t.goto(64,?120?+?10?*?i)
????t.pu()
????t.goto(56,?120?+?10?*?i)
????t.pd()
t.pu()
t.goto(60,?170)
t.pd()
t.goto(60,?180)
t.pensize(1)
#
t.pu()
t.goto(64,?190)
t.pd()
t.pencolor("#f1add1")
t.begin_fill()
for?i?in?range(360):
????x?=?drawX(4,?i)?+?60
????y?=?drawY(10,?i)?+?190
????t.goto(x,?y)
t.fillcolor("#f1add1")
t.end_fill()
#?14
t.pu()
t.goto(-56,?120)
t.pd()
t.pencolor("#b1c9e9")
t.begin_fill()
for?i?in?range(360):
????x?=?drawX(4,?i)?-?60
????y?=?drawY(1,?i)?+?120
????t.goto(x,?y)
t.goto(-56,?170)
for?i?in?range(540):
????x?=?drawX(4,?i)?-?60
????y?=?drawY(1,?i)?+?170
????t.goto(x,?y)
t.goto(-64,?120)
t.fillcolor("#b1c9e9")
t.end_fill()
t.pencolor("white")
t.pensize(2)
for?i?in?range(1,?6):
????t.goto(-56,?120?+?10?*?i)
????t.pu()
????t.goto(-64,?120?+?10?*?i)
????t.pd()
t.pu()
t.goto(-60,?170)
t.pd()
t.goto(-60,?180)
t.pensize(1)
#
t.pu()
t.goto(-56,?190)
t.pd()
t.pencolor("#f1add1")
t.begin_fill()
for?i?in?range(360):
????x?=?drawX(4,?i)?-?60
????y?=?drawY(10,?i)?+?190
????t.goto(x,?y)
t.fillcolor("#f1add1")
t.end_fill()
#?1