
範例輸入/輸出:

code:
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 19 00:29:15 2023
@author: SavingKing
"""
def chk(strr):
strr_5 = strr[:-1]
#'12345'
lis_int = [eval(i) for i in strr_5]
s0 = lis_int[0]
s2 = lis_int[2]
s4 = lis_int[4]
s1 = lis_int[1]
s3 = lis_int[3]
result = ((s0+s2+s4)+(s1+s3)*5)%26
dic = {1:"A",
2:"B",
13:"M"}
if dic[result] == strr[-1]:
check = True
else:
check=False
return check
lis=[]
for i in range(3):
strr=input("請輸入學號:\t")
lis.append(strr)
"""
12345M
55237B
03805A
"""
for ele in lis:
if chk(ele):
print("Pass")
else:
print("Fail")輸出結果:

推薦hahow線上學習python: https://igrape.net/30afN
![Python: matplotlib繪圖,如何限定座標軸範圍? plt.axis([xmin, xmax, ymin, ymax]) Python: matplotlib繪圖,如何限定座標軸範圍? plt.axis([xmin, xmax, ymin, ymax])](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2023/02/20230208101745_93.jpg?quality=90&zoom=2&ssl=1&resize=350%2C233)






![Python如何寫入docx文件? from docx import Document ; doc = Document() ; table = doc.add_table(rows=5, cols=3) ; table.cell(r,c).text = str(tabs[r][c]) ; doc.add_heading ; p = doc.add_paragraph ; p.add_run ; doc.add_picture ; 使用wordPad開啟會少最後一個row,可以用免費的LibreOffice Python如何寫入docx文件? from docx import Document ; doc = Document() ; table = doc.add_table(rows=5, cols=3) ; table.cell(r,c).text = str(tabs[r][c]) ; doc.add_heading ; p = doc.add_paragraph ; p.add_run ; doc.add_picture ; 使用wordPad開啟會少最後一個row,可以用免費的LibreOffice](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2022/09/20220914154313_30.jpg?quality=90&zoom=2&ssl=1&resize=350%2C233)


近期留言