
範例輸入/輸出:

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: pandas.Series如何只保留str,去除重複值?#isinstance(x:Any, str) -> bool #.drop_duplicates() #Series.apply( function )逐元素應用function運算 #DataFrame.apply( function )逐Series應用function運算 .drop_duplicates() 跟.unique()有何差別? df.drop_duplicates() 等效於 df[~df.duplicated()] Python: pandas.Series如何只保留str,去除重複值?#isinstance(x:Any, str) -> bool #.drop_duplicates() #Series.apply( function )逐元素應用function運算 #DataFrame.apply( function )逐Series應用function運算 .drop_duplicates() 跟.unique()有何差別? df.drop_duplicates() 等效於 df[~df.duplicated()]](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2024/11/20241123194900_0_5218de.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



![Python: matplotlib如何設定座標軸刻度? plt.xticks(seq, labels) ;如何生成fig, ax物件? fig = plt.figure(figsize= (10.24, 7.68)) ; ax = fig.add_subplot() ; fig, ax = plt.subplots(figsize=(10.24, 7.68)) ; 如何使用中文? plt.rcParams[“font.family”] = [“Microsoft JhengHei”] Python: matplotlib如何設定座標軸刻度? plt.xticks(seq, labels) ;如何生成fig, ax物件? fig = plt.figure(figsize= (10.24, 7.68)) ; ax = fig.add_subplot() ; fig, ax = plt.subplots(figsize=(10.24, 7.68)) ; 如何使用中文? plt.rcParams[“font.family”] = [“Microsoft JhengHei”]](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2023/02/20230209083006_41.png?quality=90&zoom=2&ssl=1&resize=350%2C233)


近期留言