python练习
1.分别取出0到10中的奇数和偶数
In [96]: range(1,10)
Out[96]: [1, 2, 3, 4, 5, 6, 7, 8, 9]
In [97]: range(1,10,2)
Out[97]: [1, 3, 5, 7, 9]
In [98]: range(2,10,2)
Out[98]: [2, 4, 6, 8]
2.判断一个数是否为质数
num = input(“please input a number:”)
for m in (2,num-1):
if (num%m == 0):
print (“不是质数”)
exit (0)
else:
print(“是质数”)
exit(0)
3.