###### tags: `python-TQC` # TQC+ 程式語言Python 601 偶數索引值加總 1. 題目說明: 請開啟PYD601.py檔案,依下列題意進行作答,處理偶數索引的值,使輸出值符合題意要求。作答完成請另存新檔為PYA601.py再進行評分。 2. 設計說明: 請撰寫一程式,利用一維串列存放使用者輸入的12個正整數(範圍1~99)。顯示這些數字,接著將串列索引為偶數的數字相加並輸出結果。 提示:輸出每一個數字欄寬設定為3,每3個一列,靠右對齊。 3. 輸入輸出: 輸入說明 12個正整數(範圍1~99) 輸出說明 格式化輸出12個正整數 12個數字中,索引為偶數的數字相加總合 ![](https://i.imgur.com/d1Ixelk.png) ```python= #method 1 num = [] for i in range(12): a = eval(input()) print("{:>3}".format(a),end="") if i % 2 == 0: #偶數相加 num.append(a) if i % 3 == 2: #換行 print("") print(sum(num)) #method 2 num = [] tot = 0 for i in range(12): num.append(eval(input())) print("{:>3}".format(num[i]),end="") if i % 3 == 2: print() if i % 2 == 0: tot = tot + num[i] print(tot) ```