网站首页 > 教程文章 正文
一,彩色螺旋
import turtle
t=turtle.Turtle()
a=5
color=['red','yellow','pink','brown']
t.speed(10000)
while a<=300:
for i in range(7):
t.pencolor(color[i])
t.forward(a)
t.right(91)
a=a+1
二,计算长方形的周长和面积
a=float(input("请输入长方形的长:"))
b=float(input("请输入长方形的宽:"))
s=a*b
c=2*a+2*b
print("长方形的面积是:",s)
print("长方形的周长是:",c)
三,计算圆的面积
r=int(input("请输入圆的半径:"))
s=3.14*r*r
print("圆的面积是:",s)
四,海龟跑圈
import turtle
t=turtle.Turtle()
t.pensize(20)
t.color("red")
t.up()
t.goto(50,-50)
t.down()
t.circle(50,180)
t.forward(100)
t.circle(50,180)
t.forward(100)
p=turtle.Turtle()
p.shape("turtle")
p.up()
p.goto(0,-50)
a=int(input("请输入海龟要跑的圈数:"))
for x in range(a):
print("海龟正在跑第",x+1,"圈")
p.forward(50)
p.circle(50,180)
p.forward(100)
p.circle(50,180)
p.forward(50)
五,多边形
import turtle
t=turtle.Turtle()
t.color("red")
for x in
range(10):
t.forward(100)
t.right(36)
猜你喜欢
- 2025-01-21 Python中的“锁”艺术:解锁Lock与RLock的秘密
- 2025-01-21 Python格式化字符串
- 2025-01-21 Lua实现文件I/O操作,你会吗?
- 2025-01-21 Python调用易语言动态链接库,实现验证码通杀例子
- 2025-01-21 R 语言 + aardio 快速开发图形界面、生成独立 EXE
- 2025-01-21 Python中定义函数
- 2025-01-21 Python基础语法之print和变量赋值
- 2025-01-21 java程序设计练习题(二)附答案
- 2025-01-21 c#中使用miniExcel和fastreport实现付款审批单的批量打印
- 2025-01-21 R语言实战—自学笔记—向量
- 最近发表
- 标签列表
-
- location.href (44)
- document.ready (36)
- git checkout -b (34)
- 跃点数 (35)
- 阿里云镜像地址 (33)
- qt qmessagebox (36)
- md5 sha1 (32)
- mybatis plus page (35)
- semaphore 使用详解 (32)
- update from 语句 (32)
- vue @scroll (38)
- 堆栈区别 (33)
- 在线子域名爆破 (32)
- 什么是容器 (33)
- sha1 md5 (33)
- navicat导出数据 (34)
- 阿里云acp考试 (33)
- 阿里云 nacos (34)
- redhat官网下载镜像 (36)
- srs服务器 (33)
- pico开发者 (33)
- https的端口号 (34)
- vscode更改主题 (35)
- 阿里云资源池 (34)
- os.path.join (33)