Python生日代码、生日快乐代码、生日祝福代码

您所在的位置:网站首页 祝福妈妈生日快乐的二维码 Python生日代码、生日快乐代码、生日祝福代码

Python生日代码、生日快乐代码、生日祝福代码

2024-07-12 15:40:37| 来源: 网络整理| 查看: 265

用Python画一个生日蛋糕并写上生日祝福对象及生日祝福语。画一个双层蛋糕并点上蜡烛。代码运行时间较长,请静待惊喜出现,代码运行截图: 在这里插入图片描述 另外怕大家不会使用,直接给大家准备了写好的,直接下载打开即可使用! 源码放在百度云盘上了, 需要可以微信扫描下方CSDN官方认证二维码免费领取 完整程序代码:

import turtle as t import math as m import random as r 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(width=900, height=600, startx=0, starty=0) t.title("好友,祝你生日快乐!") t.speed(2) 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() # 15 t.pu() t.goto(0, 130) t.pd() t.pencolor("#b1c9e9") t.begin_fill() for i in range(360): x = drawX(4, i) y = drawY(1, i) + 130 t.goto(x, y) t.goto(4, 180) for i in range(540): x = drawX(4, i) y = drawY(1, i) + 180 t.goto(x, y) t.goto(-4, 130) t.fillcolor("#b1c9e9") t.end_fill() t.pencolor("white") t.pensize(2) for i in range(1, 6): t.goto(4, 130 + 10 * i) t.pu() t.goto(-4, 130 + 10 * i) t.pd() t.pu() t.goto(0, 180) t.pd() t.goto(0, 190) t.pensize(1) # t.pu() t.goto(4, 200) t.pd() t.pencolor("#f1add1") t.begin_fill() for i in range(360): x = drawX(4, i) y = drawY(10, i) + 200 t.goto(x, y) t.fillcolor("#f1add1") t.end_fill() # 16 t.pu() t.goto(30, 110) t.pd() t.pencolor("#b1c9e9") t.begin_fill() for i in range(360): x = drawX(4, i) + 30 y = drawY(1, i) + 110 t.goto(x, y) t.goto(34, 160) for i in range(540): x = drawX(4, i) + 30 y = drawY(1, i) + 160 t.goto(x, y) t.goto(26, 110) t.fillcolor("#b1c9e9") t.end_fill() t.pencolor("white") t.pensize(2) for i in range(1, 6): t.goto(34, 110 + 10 * i) t.pu() t.goto(26, 110 + 10 * i) t.pd() t.pu() t.goto(30, 160) t.pd() t.goto(30, 170) t.pensize(1) # t.pu() t.goto(34, 180) t.pd() t.pencolor("#f1add1") t.begin_fill() for i in range(360): x = drawX(4, i) + 30 y = drawY(10, i) + 180 t.goto(x, y) t.fillcolor("#f1add1") t.end_fill() # 17 t.pu() t.goto(-30, 110) t.pd() t.pencolor("#b1c9e9") t.begin_fill() for i in range(360): x = drawX(4, i) - 30 y = drawY(1, i) + 110 t.goto(x, y) t.goto(-26, 160) for i in range(540): x = drawX(4, i) - 30 y = drawY(1, i) + 160 t.goto(x, y) t.goto(-34, 110) t.fillcolor("#b1c9e9") t.end_fill() t.pencolor("white") t.pensize(2) for i in range(1, 6): t.goto(-26, 110 + 10 * i) t.pu() t.goto(-34, 110 + 10 * i) t.pd() t.pu() t.goto(-30, 160) t.pd() t.goto(-30, 170) t.pensize(1) # t.pu() t.goto(-26, 180) t.pd() t.pencolor("#f1add1") t.begin_fill() for i in range(360): x = drawX(4, i) - 30 y = drawY(10, i) + 180 t.goto(x, y) t.fillcolor("#f1add1") t.end_fill() ###随机 color = ["#e28cb9", "#805a8c", "#eaa989", "#6e90b7", "#b8b68f", "#e174b5", "#cf737c", "#7c8782"] for i in range(80): t.pu() x = r.randint(-120, 120) y = r.randint(-25, 30) t.goto(x, y) t.pd() t.dot(r.randint(2, 5), color[r.randint(0, 7)]) for i in range(40): t.pu() x = r.randint(-90, 90) y = r.randint(-35, 10) t.goto(x, y) t.pd() t.dot(r.randint(2, 5), color[r.randint(0, 7)]) for i in range(40): t.pu() x = r.randint(-80, 80) y = r.randint(60, 90) t.goto(x, y) t.pd() t.dot(r.randint(2, 5), color[r.randint(0, 7)]) for i in range(30): t.pu() x = r.randint(-50, 50) y = r.randint(45, 70) t.goto(x, y) t.pd() t.dot(r.randint(2, 5), color[r.randint(0, 7)]) for i in range(50): t.pu() x = r.randint(-500, 500) y = r.randint(120, 300) t.goto(x, y) t.pd() t.dot(r.randint(3, 5), color[r.randint(0, 7)]) t.seth(90) t.pu() t.goto(0, 0) t.fd(210) t.left(90) t.fd(170) t.pd() t.write("Happy Birthday", font=("Curlz MT", 50)) t.color('blue') t.penup() t.goto(-400, 210) t.pendown() t.write('致:好友友 ', font=('楷体', 32, 'bold')) t.color('red') t.penup() t.goto(-300, 50) t.pendown() t.write('祝 你 生 日 快 乐!前 程 似 锦!', font=('楷体', 30, 'bold')) t.color('blue') t.penup() t.goto(100, -220) t.pendown() t.write('————Python代码大全', font=('楷体', 20, 'bold')) t.done() 学习资源推荐

除了上述分享,如果你也喜欢编程,想通过学习Python获取更高薪资,这里给大家分享一份Python学习资料。

这里给大家展示一下我进的最近接单的截图

私单

😝朋友们如果有需要的话,可以点击下方链接领取或者V扫描下方二维码联系领取,也可以内推兼职群哦~

🎁 CSDN大礼包,二维码失效时,点击这里领取👉:【学习资料合集&相关工具&PyCharm永久使用版获取方式】

学好 Python 不论是就业还是做副业赚钱都不错,但要学会 Python 还是要有一个学习规划。最后大家分享一份全套的 Python 学习资料,给那些想学习 Python 的小伙伴们一点帮助!

1.Python学习路线

image-20230619144606466

python学习路线图1

2.Python基础学习 01.开发工具

02.学习笔记

在这里插入图片描述

03.学习视频

在这里插入图片描述

3.Python小白必备手册

图片

4.数据分析全套资源

在这里插入图片描述

5.Python面试集锦 01.面试资料

在这里插入图片描述

在这里插入图片描述

02.简历模板

在这里插入图片描述

🎁 CSDN大礼包,二维码失效时,点击这里领取👉:【学习资料合集&相关工具&PyCharm永久使用版获取方式】

因篇幅有限,仅展示部分资料,添加上方即可获取👆 ------ 🙇‍♂️ 本文转自网络,如有侵权,请联系删除 🙇‍♂️ ------


【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭