猫史档案馆


【Python作品分享】海龟作图【作品秀】

用户:滑稽召唤师滑稽召唤师查看:1 回复:2 评论:1 创建时间:2020-07-18T19:59:47


【作品展示】

center_image

 

【作品介绍】

 

【作品源代码】

import turtle
import random


# 彩色螺旋线

t = turtle.Pen()
Error = 'Error'
t.speed(100)
colors = ['yellow', 'red', 'blue', 'green', 'purple', 'grey', 'white']
a = str(input('请选择你要画的螺旋线(按q画黑色正方形螺旋线;按w画彩色正方形螺旋线;还有e、r可以按:)'))
if (a == 'q'):
    for x in range(100):
        t.forward(x)
        t.right(90)
    t.done

if (a == 'w' or a == 'W'):
    for y in range(100):
        t.pencolor(colors[random.randint(0, 5)])
        t.forward(y)
        t.right(90)
    t.done

if (a == 'e' or a == 'E'):
    for z in range(99):
        t.pencolor(colors[random.randint(0, 5)])
        t.forward(z)
        t.left(120)
    t.done

if (a == 'r' or a == 'r'):
    for b in range(10000):
        turtle.bgcolor('black')
        t.penup()
        t.goto(random.randint((-600), 600), random.randint((-600), 600))
        t.pendown()
        t.pencolor(colors[6])
        t.dot(random.randint(1, 5))
    t.done

 

【提示】

部分含有Python第三方库相关内容的作品,在海龟编辑器网页端无法运行哦!如遇到这种情况,可以打开下面的链接,下载海龟编辑器客户端:

https://python.codemao.cn


回复

上一页1 页 / 共 1下一页
大业(大作100%100以完成)大业(大作100%100以完成)

沙发

点赞0


评论


大业(大作100%100以完成)大业(大作100%100以完成)

zpbc

点赞0


评论