# **Python 期末考** ## **學號:411008034 姓名:溫婕寧** *** ### Problem1 **程式碼** ``` import csv def main(): out=[] try: with open(students.csv,'r') as cc: ```  **結果** 無 ### Problem2 **程式碼** ``` class ID: def __init__(self, id = "0"): self.id = id def __str__(self): return f"student is {self.id}" student = ID("411123001") print(student) student = ID("411125001") print(student) student = ID("411103001") print(student) student = ID("411101001") print(student) student = ID("411123002") print(student) student = ID("411123003") print(student) student = ID("411102001") print(student) student = ID("411102002") print(student) student = ID("411103001") print(student) student = ID("411121001") print(student) class Department: def __init__(self, d = "0"): self.d = d def __str__(self): return f"student is {self.d}" student = Department("電機系") print(student) student = Department("光電系") print(student) student = Department("歷史系") print(student) student = Department("中文系") print(student) student = Department("電機系") print(student) student = Department("電機系") print(student) student = Department("英美系") print(student) student = Department("英美系") print(student) student = Department("中文系") print(student) student = Department("資工系") print(student) ```  **結果**  ### Problem3 **程式碼** ``` import re import csv def main(): check(id) out=[] f = open('information.txt') for row in f.readlines(): out.append(row) print(out) f.close if id in out: print(f'{"tel"}') else: print('ID is not exist.') def check(id): while True: id=input('input st:') if re.search('[a-zA-Z0-9]{7,11}',id): return True else: print('Wrong ID,please try again.') continue if __name__=="__main__": main() ```  **結果** 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up