python练习1

#coding=utf8
#输出9*9乘法口诀表
for i in range(1,10):
    for j in range(1,10):
        print (i*j),
    print ""
#coding=utf8
#输入一个3位数,判断是否是水仙花数
def sxh(a):
    x=a%10
    y=int(a/10)%10
    z=int(a/100)%10
    if x**3+y**3+z**3==a:
        print "%d是水仙花数!" %a
if __name__=='__main__':
    for i in range(100,1000):
        sxh(i)
#coding=utf8
#求 100 之内的素数
for i in range(2, 100):
    for j in  range(2,i+1):
        if i%j==0:
            break
        else:
            print "%d is a prime!" %i
            break

你可能感兴趣的:(学习)