TQC+ 程式語言Python 408 奇偶數個數計算
題目說明:
請撰寫一程式,讓使用者輸入十個整數,計算並輸出偶數和奇數的個數。
範例輸入
69
48
19
91
83
22
18
37
82
40
範例輸出
Even numbers: 5
Odd numbers: 5
程式碼:
Even = Odd = 0
for i in range(10):
if eval(input()) % 2 == 0:
Even += 1
else:
Odd += 1
print('Even numbers: %d' %Even)
print('Odd numbers: %d' %Odd)