發表文章

目前顯示的是 3月, 2024的文章

劉子鳴Python自訂函數迴圈write模式a與w

圖片
上面的程式碼 <style> h1{background-color: black; color: white; border: 10px solid red; text-align:center; padding: 5px} ul{background-color: green; color: white; font-size: 2em;} </style>   VS code截圖 程式碼 space, slash, backslash, cr = ' ', '/', '\\', '\n' def row1(k,m):#定義自訂函數 for i in range(1, k+1): for ii in range(m): for j in range(k-i): f.write(space) f.write(slash) for j in range(2*i-2): f.write(space) f.write(backslash) for j in range(k-i): f.write(space) f.write(cr) def row2(r,m): for i in range(1, k+1): for ii in range(m): for j in range(i-1): f.write(space) f.write(backslash) for j in range(2*k-2*i): f.write(space) f.write(slash) for j in range(i-1): f.write(space) f.write(...

劉子鳴開啟資料夾編輯檔案

圖片

劉子鳴python檔案方法

圖片

劉子鳴python內建built-in函數function迴圈loop範圍range

圖片
程式碼 print("練習函數abs, all, any, ascii") for i in range(-2,3): x = abs(i) print(abs(x)) print("all邏輯,是否全部是真?") x, y, z = 1==1, 2>1, 3>2 #=給值,==判斷 print(all([x,y,z])) print("2>1,-1==1,-2>3有正確的嗎",any([2>1, -1==1, -2>3])) print("2>1,-1==1,-2>3全正確嗎",all([2>1, -1==1, -2>3])) #pthon註解range(開始,結束) print("列印,迴圈for, range範圍") for i in range(33301, 33344): print("字碼character", i,"是",chr(i)) for i in range(65, 70): print(chr(i)) w3school內建函數列表 https://www.w3schools.com/python/python_ref_functions.asp Python has a set of built-in functions. 單元373