
範例輸入/輸出:

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://i1.wp.com/savingking.com.tw/wp-content/uploads/2024/11/20241123194900_0_5218de.png?quality=90&zoom=2&ssl=1&resize=350%2C233)


![Python: 如何求整個 pandas.DataFrame 中的最大值? pandas.DataFrame .max().max() ; 如何求最大值的index, columns? numpy.where(condition, [x, y, ]/) ; condition為一 bool_mask Python: 如何求整個 pandas.DataFrame 中的最大值? pandas.DataFrame .max().max() ; 如何求最大值的index, columns? numpy.where(condition, [x, y, ]/) ; condition為一 bool_mask](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2023/04/20230418154049_50.png?quality=90&zoom=2&ssl=1&resize=350%2C233)
![Excel TQC考題208: Competition,自訂格式: [<=50]0; 頁面配置>版面設定 展開>頁首/頁尾 Excel TQC考題208: Competition,自訂格式: [<=50]0; 頁面配置>版面設定 展開>頁首/頁尾](https://i0.wp.com/savingking.com.tw/wp-content/uploads/2022/04/20220411102844_81.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



近期留言