使用turtle换一个五环:
>>> import turtle #导入模块
>>> turtle.width(10) #设置圆圈宽度
>>> turtle.color("blue") #设置颜色
>>> turtle.circle(50) #设置半径
>>> turtle.color("black")
>>> turtle.penup() #抬笔
>>> turtle.goto(120,0) #坐标
>>> turtle.pendown() #落笔
>>> turtle.circle(50)
>>> turtle.color("red")
>>> turtle.penup()
>>> turtle.goto(240,0)
>>> turtle.pendown()
>>> turtle.circle(50)
>>> turtle.color("yellow")
>>> turtle.penup()
>>> turtle.goto(60,-50)
>>> turtle.pendown()
>>> turtle.circle(50)
>>> turtle.color("green")
>>> turtle.penup()
>>> turtle.goto(180,-50)
>>> turtle.pendown()
>>> turtle.circle(50)
设计这样一个程序:输入一个数字 判断它是不是一个质数:
a = int(input("请输入一个数字:"))
b = 2
while b < a :
if a % b == 0 :
print ("该数字不是质数")
break
b += 1
else:
print("该数字是质数")
break