对一个列表里的数据进行奇偶数分离 numbers = [12, 37, 5, 42, 8, 3] even = [] odd = [] while len(numbers) > 0 : number = ( ) if(number % 2 == 0): even.append(number) else: odd.append(number) print even print odd
举一反三
- The even number is yang while the odd number is yin.
- 以下程序的输出结果是___________。 number = 10 if number % 2 == 0: print(number, 'is even') elif number % 5 == 0: print(number, 'is multiple of 2')
- In Russia, flowers are very well received but ensure they are an odd number, because even numbers are considered bad luck and are associated with funerals.
- The number of elements of order 2 in even order groups must be odd
- 中国大学MOOC: 以下程序的输出结果是?number = 30if number % 2 == 0: print(number, is even)elif number % 3 == 0: print(number, is multiple of 3)