import turtle
a = "on"
b = "on"
# 绘制电池
turtle.pencolor("orange")
turtle.fillcolor("green")
turtle.begin_fill()
turtle.pensize(5)
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.forward(100)
turtle.left(90)
turtle.forward(50)
turtle.left(90)
turtle.end_fill()
# 绘制电线
turtle.penup()
turtle.goto(100,25)
turtle.pendown()
turtle.goto(200,25)
turtle.goto(200,125)
turtle.goto(-50,125)
turtle.goto(-50,25)
turtle.goto(0,25)
turtle.penup()
turtle.goto(150,125)
turtle.pendown()
if a == "on" and b == "off":
turtle.pencolor("yellow")
turtle.dot(40)
else:
turtle.pencolor("black")
turtle.dot(40)
turtle.done()
少儿编程 Python 绘制电路 分支结构
最新推荐文章于 2024-03-12 01:40:01 发布