当前位置 : 主页 > 编程语言 > python >

py画图_分界线画正方形(大于0为红色,小于为绿色)

来源:互联网 收集:自由互联 发布时间:2022-06-18
from 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' ) else : c


from 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')
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()



上一篇:python判断素数
下一篇:没有了
网友评论