如何用Python绘制分界线正方形,颜色随数值变化(大于0为红,小于0为绿)?
- 内容介绍
- 文章标签
- 相关推荐
本文共计138个文字,预计阅读时间需要1分钟。
pythonfrom turtle import *from random import *
speed(0)penup()goto(-190, 0)pendown()
for j in range(20): x=randint(-200, 200) y=randint(-200, 200) penup() goto(x, y) pendown() if x !=0: color('red')
from random import *
speed(0)
penup()
goto(-190,0)
pendown()
for j in range(20):
x=randint(-200,200)
y=randint(-200,200)
penup()
goto(x, y)
pendown()
if x>0:
color('red')
else:
color('green')
begin_fill()
for i in range(4):
fd(30)
left(90)
end_fill()
# penup()
# goto(-190+(j+1)*50, 0)
# pendown()
input()
本文共计138个文字,预计阅读时间需要1分钟。
pythonfrom turtle import *from random import *
speed(0)penup()goto(-190, 0)pendown()
for j in range(20): x=randint(-200, 200) y=randint(-200, 200) penup() goto(x, y) pendown() if x !=0: color('red')
from random import *
speed(0)
penup()
goto(-190,0)
pendown()
for j in range(20):
x=randint(-200,200)
y=randint(-200,200)
penup()
goto(x, y)
pendown()
if x>0:
color('red')
else:
color('green')
begin_fill()
for i in range(4):
fd(30)
left(90)
end_fill()
# penup()
# goto(-190+(j+1)*50, 0)
# pendown()
input()

