用户:
炸图监管者查看:0 回复:0 评论:0 创建时间:2021-05-28T19:43:06
【作品展示】

【作品介绍】
使用海龟,if语句,
【作品源代码】
import turtle
print("欢迎使用中文海龟画图编辑器")
print("支持语法:颜色 底色 走路 旋转 画板 粗细 抬笔 落笔 隐藏 速度 移动 移动X 移动Y 清除 归位 重置 绘制 文字 输入帮助获取")
while True:
a = input(">>>")
if a == "画板":
turtle.Pen()
if a == "粗细":
cu = input("粗细:")
turtle.pensize(cu)
if a == "颜色":
e = input('颜色[红/绿/蓝/橙/黄/黑/白/粉/紫]:')
if e == "红":
turtle.color('red')
if e == '绿':
turtle.color('green')
if e == '蓝':
turtle.color('blue')
if e == '橙':
turtle.color('orange')
if e == '黄':
turtle.color('yellow')
if e == '黑':
turtle.color('black')
if e == '白':
turtle.color('white')
if e == '粉':
turtle.color('pink')
if e == '紫':
turtle.color('purple')
if a == '走路':
bu = int(input('步数:'))
turtle.fd(bu)
bu = 0
if a == '旋转':
zhuan = int(input('度数:'))
turtle.left(zhuan)
if a == '底色':
s = input('颜色[红/绿/蓝/橙/黄/黑/白/粉/紫]:')
if s == '红':
turtle.bgcolor('red')
if s == '绿':
turtle.bgcolor('green')
if s == '蓝':
turtle.bgcolor('blue')
if s == '橙':
turtle.bgcolor('orange')
if s == '黄':
turtle.bgcolor('yellow')
if s == '黑':
turtle.bgcolor('black')
if s == '白':
turtle.bgcolor('white')
if s == '粉':
turtle.bgcolor('pink')
if s == '紫':
turtle.bgcolor('purple')
if a == '速度':
sudu = int(input('速度[1-100]:'))
turtle.speed(sudu)
if a == '抬笔':
turtle.penup()
if a == '落笔':
turtle.pendown()
if a == "隐藏":
turtle.hideturtle()
if a == "移动":
yiX = int(input('X:'))
yiY = int(input("Y:"))
turtle.goto(yiX, yiY)
if a == '移动X':
XXX = int(input('X:'))
turtle.setx(XXX)
if a == '移动Y':
YYY = int(input('Y:'))
turtle.sety(YYY)
if a == "清除":
turtle.clear()
if a == "归位":
turtle.home()
if a == '重置':
turtle.reset()
if a == "帮助":
print("支持语法:颜色 底色 走路 旋转 画板 粗细 抬笔 落笔 隐藏 速度 移动 移动X 移动Y 清除 归位 重置 绘制 文字")
if a == "绘制":
print("圆形 正方形 长方形 退出")
h = input("选择:")
if h == "退出":
continue
if h == "圆形":
shi = input("空心/实心:")
zhj = int(input("直径:"))
if shi == "空心":
turtle.circle(zhj)
if shi == "实心":
turtle.dot(zhj)
if h == '正方形':
an = int(input("边长:"))
turtle.fd(an)
turtle.left(90)
turtle.fd(an)
turtle.left(90)
turtle.fd(an)
turtle.left(90)
turtle.fd(an)
turtle.left(90)
continue
if h == "长方形":
chang = int(input('长:'))
kuan = int(input('宽:'))
if chang > kuan:
heng = input("横/竖:")
if heng == "横":
turtle.fd(chang)
turtle.left(90)
turtle.fd(kuan)
turtle.left(90)
turtle.fd(chang)
turtle.left(90)
turtle.fd(kuan)
turtle.left(90)
print("OK")
continue
if heng == '竖':
turtle.fd(kuan)
turtle.left(90)
turtle.fd(chang)
turtle.left(90)
turtle.fd(kuan)
turtle.left(90)
turtle.fd(chang)
turtle.left(90)
continue
else:
print("长方形错误")
continue
if a == "文字":
wenzi = input("输出:")
zdx = int(input("大小:"))
turtle.write(wenzi, font=('Arial', zdx, 'normal'))
if a == "显示":
turtle.showturtle()
【提示】
部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:
https://python.codemao.cn