糖葫芦
import turtle
turtle.forward(100)
turtle.dot(20,"red")
turtle.forward(25)
turtle.dot(30,"orange")
turtle.forward(35)
turtle.dot(40,"yellow")
turtle.forward(45)
turtle.dot(50,"green")
turtle.done()
瞄准镜
import turtle
turtle.pensize(15)
turtle.speed(5)
turtle.penup()
turtle.goto(0,-200)
turtle.pendown()
turtle.circle(200)
turtle.left(90)
turtle.forward(400)
turtle.penup()
turtle.goto(200,0)
turtle.pendown()
turtle.goto(-200,0)
turtle.goto(-100,0)
turtle.forward(20)
turtle.backward(40)
turtle.penup()
turtle.goto(100,0)
turtle.pendown()
turtle.forward(20)
turtle.backward(40)
turtle.penup()
turtle.goto(0,100)
turtle.pendown()
turtle.right(90)
turtle.forward(20)
turtle.backward(40)
turtle.penup()
turtle.goto(0,-100)
turtle.pendown()
turtle.forward(20)
turtle.backward(40)
turtle.done()
绘制彩虹
import turtle
p = turtle.Pen()
p.speed(0)
# 绘制红色彩虹
p.pensize(30)
p.seth(90)
p.penup()
p.goto(200,0)
p.pendown()
p.pencolor("red")
p.circle(200,180)
# 绘制橙色彩虹
p.penup()
p.goto(190,0)
p.pendown()
p.pensize(25)
p.seth(90)
p.pencolor("orange")
p.circle(190,180)
# 绘制黄色彩虹
p.penup()
p.goto(180,0)
p.pendown()
p.pensize(23)
p.seth(90)
p.pencolor("yellow")
p.circle(180,180)
#绘制绿色彩虹
p.penup()
p.goto(170,0)
p.pendown()
p.pensize(21)
p.seth(90)
p.pencolor("green")
p.circle(170,180)
#绘制青色彩虹
p.penup()
p.goto(160,0)
p.pendown()
p.pensize(18)
p.seth(90)
p.pencolor("cyan")
p.circle(160,180)
#绘制蓝色彩虹
p.penup()
p.goto(150,0)
p.pendown()
p.pensize(15)
p.seth(90)
p.pencolor("blue")
p.circle(150,180)
#绘制紫色彩虹
p.penup()
p.goto(140,0)
p.pendown()
p.pensize(12)
p.seth(90)
p.pencolor("purple")
p.circle(140,180)
turtle.done()
填充颜色 月亮 星星
import turtle
a = turtle.Pen()
turtle.bgcolor("skyblue")
a.fillcolor("yellow")
a.begin_fill()
a.circle(100,180)
a.left(135)
a.circle(-140,90)
a.end_fill()
a.circle(-140,-23)
a.left(90)
a.pencolor("orange")
a.pensize(5)
a.circle(20,90)
a.penup()
a.goto(60,170)
a.pendown()
a.seth(135)
a.circle(20,90)
a.penup()
a.goto(45,160)
a.pendown()
a.dot(20,"black")
a.penup()
a.goto(-110,250)
a.pendown()
a.begin_fill()
a.fd(100)
a.right(144)
a.fd(100)
a.right(144)
a.fd(100)
a.right(144)
a.fd(100)
a.right(144)
a.fd(100)
a.right(144)
a.end_fill()
turtle.done()
红绿灯
import turtle
import time
p = turtle.Pen()
t = turtle.Pen()
p.penup()
p.goto(-100,-200)
p.pendown()
p.pensize(15)
p.left(90)
p.fd(400)
p.right(90)
p.fd(200)
p.right(90)
p.fd(400)
p.right(90)
p.fd(200)
t.penup()
t.goto(0,100)
t.pendown()
t.dot(100,"green")
time.sleep(5)
t.clear()
t.penup()
t.goto(0,0)
t.pendown()
t.dot(100,"yellow")
time.sleep(5)
t.clear()
t.penup()
t.goto(0,-100)
t.pendown()
t.dot(100,"red")
time.sleep(5)
turtle.done()
cls08 eval
num1 = int(input("请输入第一个数字"))
num2 = int(input("请输入第二个数字"))
result1 = num1+num2
result2 = num1-num2
result3 = num1*num2
result4 = num1/num2
result5 = num1%num2
print(result1,result2,result3,result4,result5)
import turtle
p = turtle.Pen()
a = input("请输入一个算式")
b = eval(a)
p.write(a+"="+str(b),font = ("arial",40,"normal"),align="center")
turtle.done()
电路图
import turtle
a = False
p = turtle.Pen()
p.hideturtle()
p.color("orange", "green")
p.pensize(5)
p.penup()
p.goto(0, 100)
p.pendown()
p.fd(150)
p.right(90)
p.fd(200)
p.right(90)
p.fd(150)
p.begin_fill()
p.left(90)
p.fd(30)
p.right(90)
p.fd(100)
p.right(90)
p.fd(60)
p.right(90)
p.fd(100)
p.right(90)
p.fd(30)
p.end_fill()
p.penup()
p.goto(-100, -100)
p.pendown()
p.right(90)
p.fd(50)
p.right(90)
p.fd(200)
p.right(90)
p.fd(150)
if a:
p.dot(100, "yellow")
else:
p.dot(100, "black")
turtle.done()
黄白灯
import turtle
p = turtle.Pen()
t = turtle.Pen()
a = True
b = False
if a==True and b==True:
p.fillcolor("yellow")
else:
p.fillcolor("white")
p.penup()
p.goto(0,-200)
p.pendown()
p.begin_fill()
p.circle(200)
p.end_fill()
t.fillcolor("grey")
t.penup()
t.goto(0,-190)
t.pendown()
t.begin_fill()
t.fd(50)
t.right(90)
t.fd(50)
t.right(90)
t.fd(100)
t.right(90)
t.fd(50)
t.right(90)
t.fd(50)
t.end_fill()
turtle.done()