Python-list用求模分表

2019-04-13 15:11发布

list1=[] for i in range(100): list1.append(i) server01=[] server02=[] server03=[] server04=[] for i in list1: if i%4==0: server01.append(i) elif i%4==1: server02.append(i) elif i%4==2: server03.append(i) else : server04.append(i) print(list1) print(server01) print(server02) print(server03) print(server04) num=int(input('Please input a number:')) if num>=100 or num <=-1: print('请输入》=0并且《=99的整数数字:') num = int(input('Please input a number:')) if num %4==0: for i in server01: if num==i: print('我已经在server01找到你了--%d'%i) elif num %4==1: for i in server02: if num==i: print('我已经在server02找到你了--%d'%i) elif num %4==2: for i in server03: if num==i: print('我已经在server03找到你了--%d'%i) elif num %4==3: for i in server04: if num==i: print('我已经在server04找到你了--%d'%i) /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 /Users/apple/PycharmProjects/stage4/Pool/modulo.py
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]
[0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96]
[1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97]
[2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 86, 90, 94, 98]
[3, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99]
Please input a number:100
请输入》=0并且《=99的整数数字:
Please input a number:99
我已经在server04找到你了--99