
範例輸入/輸出:

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 正規表達式教學:看懂 re.split()、\W|_ 與 flags=re.ASCII # \w代表 word character ~ [A-Za-z0-9_] Python 正規表達式教學:看懂 re.split()、\W|_ 與 flags=re.ASCII # \w代表 word character ~ [A-Za-z0-9_]](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2026/04/20260430085117_0_0beced.png?quality=90&zoom=2&ssl=1&resize=350%2C233)


]*>.*?底下插入一個圖檔.*?</w:p>’, flags = re.DOTALL) ; new_xml, n = pattern.subn(”, xml, count=1)' title='Python正則替換:全面掌握 re.sub 與 re.subn 的差異與實戰 #substitute(替換); . 預設匹配「除\n以外的任意單一字元」; pattern = re.compile(r'<w:p[^>]*>.*?底下插入一個圖檔.*?</w:p>’, flags = re.DOTALL) ; new_xml, n = pattern.subn(”, xml, count=1)' loading='lazy' width=350 height=233 />![Python四種型態增加元素 list.append(元素), tuple = tuple + (元素, ), set.add(元素), dict[key]=value Python四種型態增加元素 list.append(元素), tuple = tuple + (元素, ), set.add(元素), dict[key]=value](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2022/05/20220513083711_22.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

近期留言