python绘制颜色随机的花瓣 编写程序
1条回答 默认 最新
- CSDN专家-sinJack 2021-11-17 09:55关注
#导入turtle模块 import turtle window=turtle.Screen() #创建一个新窗口用于绘图 babbage=turtle.Turtle() #创建一个名字叫babbage的turtle对象 babbage.color("green","black") babbage.left(90) #使babbage左转90° babbage.forward(100) #向前移动了100像素 babbage.right(90) #右转90° babbage.color("black","black") babbage.begin_fill() #为圆填充颜色 babbage.circle(10) #画个半径为10像素的圆 babbage.end_fill() #画第N个花瓣 for i in range(1,24): if babbage.color()==("red","black"): babbage.color("orange","black") elif babbage.color()==("orange","black"): babbage.color("yellow","black") else: babbage.color("red","black") babbage.left(15) babbage.forward(50) babbage.left(157) babbage.forward(50) babbage.hideturtle() window.exitonclick() #定义单击窗口就可以将其关闭
解决 无用评论 打赏 举报
悬赏问题
- ¥50 array数据同步问题
- ¥15 pic16F877a单片机的外部触发中断程序仿真失效
- ¥15 Matlab插值拟合差分微分规划图论
- ¥15 keil5 target not created
- ¥15 C/C++数据与算法请教
- ¥15 怎么找志同道合的伙伴
- ¥20 如何让程序ab.eXe自已删除干净硬盘里的本文件自己的ab.eXe文件
- ¥50 爬虫预算充足,跪巨佬
- ¥15 滑块验证码拖动问题悬赏
- ¥15 Wanted but not invoked:Actually, there were zero interactions with this moc