Python 练习 21

#!/usr/bin/python
# -*- coding: UTF-8 -*-

h = 0
leap = 1
from math import sqrt
from sys import stdout
for m in range(101,201):
    k = int(sqrt(m + 1))
    for i in range(2,k + 1):
        if m % i == 0:
            leap = 0
            break
    if leap == 1:
        print '%-4d' % m
        h += 1
        if h % 10 == 0:
            print ''
    leap = 1
print 'The total is %d' % h

 

posted @ 2016-05-26 17:05  七月的尾巴_葵花  阅读(199)  评论(0编辑  收藏  举报