Python TQC考題302_迴圈偶數連加 by 儲蓄保險王 · 2022-04-28 #Python TQC考題302_迴圈偶數連加 a=eval(input()) b=eval(input()) sum=0 for i in range(a,b+1): if i%2==0: sum+=i #sum=sum+i print(sum) 相關文章Python:如何串接Gemini API?如何傳遞圖片給API?如何將回應的base64 str轉回圖片?如何看消耗的tokens?Python 核心技巧:從俄羅斯娃娃看懂「遞迴走訪 (recursive traversal)」與 AST 語法樹Python: pandas.DataFrame.drop()的參數axis=0 / 1 vs index / columns ; 如何drop DataFrame的rows / columns ?Python: 如何使用pandas.to_numeric ( df['numbers'], errors='coerce') 將非數值型資料轉為NaN? df['numbers'].describe() 簡述統計資料Python: 深入理解 pandas.concat():使用 ignore_index=True 合併 DataFrame 的奧秘 #效果同 reset_index( drop=True )Python: 前綴f string 格式化字串 hex_string = f'0x{value :02x}' #:02x or :08b是格式化說明符(format specifier) ; hex() or bin() #轉為16 or 2進位數字,會省略前導0華為HUAWEI MediaPad X2 7吋八核雙卡通話平板(LTE版/16G)Python IDE(Integrated Development Environment 整合開發環境) colab如何掛載雲端硬碟?from google.colab import drive; drive.mount( '/content/drive' ) ; 檔案複製shutil.copy() #shell utility; 檔案移動shutil.move( source_file, destination_path); 刪除整個資料夾shutil.rmtree( folder_to_delete ); 刪除某一個檔案os.remove() #shutil.remove()會觸發AttributeError; 如何將檔案路徑拆分為父資料夾與檔案名稱(含副檔名)? os.path.dirname( file_path) ; os.path.basename( file_path) 如何將檔案名稱拆分為主檔名與副檔名? os.path.splitext( file_name) #split(分裂) ext的意思Python 正則表示法(Regular Expression) : re.Match 物件的 .group() .groups()方法 #捕獲組
0 Python 實戰:用 jieba + Normalize + N-gram 穩定抓出 Family 名稱 ; re.sub(r'[^a-z0-9]+’, ”, s.lower()) #全部轉小寫 #移除非英數字元 2026-04-27
近期留言