- 首页 > it技术 > >
#判断2-10000之间有多少素数 并输出所有素数
count=0
for num in range(2,100001):
for x in range(2,num):
if num %x==0:
breakelse:
count += 1
print(num,'是素数')
print('素数的个数:',count)
画出九宫格
import turtlec = turtle.Turtle()ponit_list=[(-300,0),(-200,0),(-100,0),
(-300,-100),(-200,-100),(-100,-100),
(-300,-200),(-200,-200),(-100,-200)]
c.speed(10)
def move(x,y):
c.penup()
c.goto(x,y)
c.pendown()
# 画一个正方形
def square():
for i in range(4):
c.forward(100)
c.right(90)for i in range(9):
move(*ponit_list[i])
square()
推荐阅读